<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>险种添加</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
<style type="text/css">
.input_text{
width: 250px;
}
.select_1{
width: 250px;
}
</style>
<script src="js/jquery.validate.js" type="text/javascript" ></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>


<script type="text/javascript">
// 用于存放已选择的险种
var riskMap = new Map();
var startP=1;
var startPlan=1;
var Formstatus=true;
var tradProdCode='${tradProdCode}';
var currCoreProdCode='${currCoreProdCode}';
var chooseCoreProdCode='${currCoreProdCode}';
var chooseCoreRiskCode= "";
var chooseCorePrmryFlag= "";
var riskType= "";
var count2=1;
var count4=1;
var carType=new Map();
var calDefIdAll = ""// 全局算法代码
var covIdAll = "";// 全局责任代码
var tradPlanCodeFlag = "";//全局交易系统险种
var tradPlanCodeAll=""; //产品号
var map = new Map();
var minDays = "";// 最小保险期间
var maxDays = "";// 最大保险期间
var count=1;
var count1=1;
var count3=1;
var count5=1;
var maxYeay=0;
var smallYeay=0;
var minAge="";//最小保险年龄
var maxAge="";//最大保险年龄

//0：选择；1-（隐藏）产品号；2-责任代码；3-责任名称；4-责任别名；5-9（隐藏)；10-短期费率标志；11-保额（两个下拉框，一个输入框）
//12-保额占比 ；13-保额上限；14-免赔额；15-赔付比例；16-责任保费算法；
//通用算法
var callLists='000000000801,000000000802,000000000803,000000000804,000000000806,000000000807,000000000809,000000000810,000000000812,000000000813,000000000814,000000000815'
//自定义map功能
/*---------------------Map 构造开始---------------------------------*/
function Map(){
   this.elements = new Array();
   //获取MAP元素个数
   this.size = function() {
       return this.elements.length;
   };
   //判断MAP是否为空
   this.isEmpty = function() {
       return (this.elements.length < 1);
   };
   //删除MAP所有元素
   this.clear = function() {
       this.elements = new Array();
   };
   //向MAP中增加元素（key, value)
   this.put = function(_key, _value) {
       if(this.containsKey(_key)){
        this.remove(_key);
        this.elements.push( {
           key : _key,
           value : _value
        });
       }else{
        this.elements.push( {
           key : _key,
           value : _value
        });
       }
   };
   //删除指定KEY的元素，成功返回True，失败返回False
   this.remove = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   this.elements.splice(i, 1);
                   return true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
   //获取指定KEY的元素值VALUE，失败返回NULL
   this.get = function(_key) {
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   return this.elements[i].value;
               }
           }
       } catch (e) {
           return "";
       }
       return "";
   };
   //判断MAP中是否含有指定KEY的元素
   this.containsKey = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   bln = true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
  //获取map的所有values
  this.values = function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].value);
       }
       return arr;
   };
  //获取map的所有keys
  this.keys= function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].key);
       }
       return arr;
   };
   //获取数组
   this.getArray= function(){
   	var arr = new Array();
   	for (var i = 0; i < this.elements.length; i++) {
           arr.push({
	            key : this.elements[i].key,
	            value : this.elements[i].value
	         });
       }
       return arr;
   };
};
/*---------------------Map 构造完成---------------------------------*/
$(document).ready(function() {
	$("#coreProdTempletCode").change(function(){
		queryNewLifeProdRisk(1);
	});
	loadRisk({current:1,size:6,tradProdCode:tradProdCode});
});
//导入数据
function reconciliationFileChose(){
	var reconciliationFile=$("#reconciliationFile").val();
	if(reconciliationFile.length == 0){
		$.message("error","请先选择更新文件");
		return;
	}
	if(reconciliationFile.substr(reconciliationFile.lastIndexOf(".")) != ".xls"){
		$.message("error", "必须选择xls格式的文件");
		return;
	}
	$.ajaxFileUpload({
	    url:'<%=path%>/product/feeRate/calTemplateImport1?calDefId='+calDefIdAll+'&prodCode='+tradPlanCodeAll,
	    fileElementId :'reconciliationFile',//file控件id
	    dataType: 'json',
	    success : function (data){
	    	if(data.result==false){
	    		$.message("error","导入失败请检查数据或联系管理员");
	        	return;
	      }else if(data.result){
	    	  closeCalTemplateImportDiv();
	    	  if(calDefIdAll!='000000000877'){
	    		  var tableHtml = getTableHtml(data);
					if(tableHtml == undefined) {
						$.message("error","该险种算法配置有误，请检查数据库中对应的算法表或联系管理员");
						return;
					}
					var calTd = $('#calTd');
					calTd.empty();
					calTd.prepend(tableHtml);
	    	  }else{
	    		  for (var i = 0; i < data.calls.length; i++) {
	    			  var call=data.calls[i];
	    			  adddept11(call);
	    			  $('#cond3'+count1).val(call.cond3)
	    			  $('#cond7'+count1).val(call.cond7)
	    			  $('#premRate'+count1).val(call.premRate)
	    			  $('#cond1'+count1).val(call.cond1)
	    			  $('#cond2'+count1).val(call.cond2)
	    			  $('#cond10'+count1).val(call.cond10)
				}
	    	  }
			$.message("success","导入成功");
            }
	    }
	});
}
/* ----------------------核保规则---------------------- */
function saveAuwConfig(){
	var selectedAuw = $("input[name='auwarr']:checked");
	var auwConfigListStr ='';
	if(selectedAuw.length!=0){
		selectedAuw.each(function(i){
			var obj = new Object();
			obj.id= $(this).parent().parent().children("td:eq(1)").html();
			map.put(obj.id,obj);
		});
	}
	if(!map.isEmpty()){
		var auwConfigList = new Array();
		for(i in map.keys()){
	        var key = map.keys()[i];
	        auwConfigList.push(map.get(key));
	    }
		auwConfigListStr=JSON.stringify(auwConfigList);
	}
	updateAuwConfig({tradProdCode:tradProdCode,auwConfigListStr:auwConfigListStr});
	closeAuwConfigDiv('auwConfigDiv');
}
//执行更新
function updateAuwConfig(param){
	$.openLoading();
	$.ajax({
		url : "<%=path%>/product/feeRate/setAuwConfigsToProd1",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(data){
			$.closeLoading();
			if($.validate(data))return;
		}
	});
}
//统一 关闭  窗口
function closeAuwConfigDiv(obj){
	map.clear();
	$("#auwConfigsDivTable").find("tr").each(function(){
		$(this).children("td:eq(0)").find("input[name='auwarr']").prop("checked",false);
	});
    $("#"+obj).CloseDiv();
}

// 打开产品窗口
function openAuwConfigDiv(pageIndex){
	$.ajax({
		url : "<%=path%>/product/feeRate/queryAuwConfigsByProd",
		type : 'POST',
		async : false,
		data:{"tradProdCode":tradProdCode},
		dataType:'json',
		success:function(data){
			if(data[0]!=undefined){
				map.clear();//清空备份map
				$.each(data,function(i,item){
		        	var obj = new Object();
		        	obj.id = item.configId;
		        	map.put(obj.id,obj);
				})
			}
		}
	});
	queryAuwConfigs(pageIndex);
}
//调用拼接参数的方法，并执行查询
function queryAuwConfigs(pageIndex){
	var size = 10;
	// 翻页时会用到如下代码
	var selectedAuw = $("input[name='auwarr']:checked");
	if(selectedAuw.length!=0){
		selectedAuw.each(function(i){
			var obj = new Object();
			obj.id= $(this).parent().parent().children(" td:eq(1)").html();

			map.put(obj.id,obj);
		});
	}
	// 翻页时用如上代码
	loadAuwConfig({size:size,pageIndex:pageIndex,tradProdCode:tradPlanCodeAll});
}
//配置代理信息
function loadAuwConfig(param){
	$.openLoading();
	$.ajax({
		url : "<%=path%>/product/feeRate/queryAuwConfigsByPage",
		type : 'POST',
		async : false,
		data:param,
		dataType:'json',
		success:function(configPage){
			$.closeLoading();
			if($.validate(configPage))return;
				var checkboxObj ="<input name='auwarr' type='checkbox'>";
				var fieldNames = "configId,configDesc";
				var tableContent = creatTable1(fieldNames,configPage,checkboxObj,null);
				var tableObj = $("#auwConfigsDivTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage4(param.pageIndex,6,configPage.maxPage,"59");
				var pageDIV = $("#userRoleDivPage");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$("#auwConfigsDivTable").find("tr").each(function(){
					var id = $(this).children(" td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='auwarr']").prop("checked",true);
					}else{
						$(this).removeClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='auwarr']").prop("checked",false);
					}
				});
				checkAll();
				bindradioSS();
				$('#auwConfigDiv').OpenDiv();
		}
	});
}
//绑定单选按钮事件，选中某个单选按钮，该按钮所在行高亮显示
function bindradioSS(){
	$("input[name='auwarr']").click(function(){
		var id= $(this).parent().parent().children(" td:eq(1)").html();
		if($(this).prop("checked")){//选中
			$(this).parent().parent().addClass("table_highlighter");
			var obj = new Object();
			obj.id =id;
			map.put(obj.id,obj);
			checkAll();
		}else{//取消选中
			$(this).parent().parent().removeClass("table_highlighter");
			$(this).prop("checked",false);
			map.remove(id);
			$("#auwConfigCheckAll").prop("checked",false);
		}
	});
	$("#auwConfigCheckAll").click(function(){
		if($(this).prop("checked")){//选中
			$("#auwConfigsDivTable tbody tr").each(function() {
				$(this).find("input[name='auwarr']").prop("checked",true);
				$(this).addClass("table_highlighter");
				var obj = new Object();
				var id= $(this).children(" td:eq(1)").html();
				obj.id =id;
				map.put(obj.id,obj);
			});
		}else{//取消选中
			$("#auwConfigsDivTable tbody tr").each(function() {
				$(this).removeClass("table_highlighter");
				$(this).find("input[name='auwarr']").prop("checked",false);
				var id= $(this).children(" td:eq(1)").html();
				map.remove(id);
			});
		}
	});
}
function checkAll(){
	var flag = false;
	$("#auwConfigsDivTable tbody").find("tr").each(function(){
		var id = $(this).children(" td:eq(1)").html();
		if(!$(this).children("td:eq(0)").find("input[name='auwarr']").prop("checked")){
			flag = true;//如果有未选择的
		}
	});
	if(flag){
		$("#auwConfigCheckAll").prop("checked",false);
	}else{
		$("#auwConfigCheckAll").prop("checked",true);
	}
}
/**------------------------核保规则结束----------------------------------*/
//算法excel数据导入
function calTemplateImport(){
	$("#calTemplateImportDiv").css({"width":"50%","height":"135px"});
	$("#chooseReconciliationFileForm").css("display","block");
	$("#calTemplateImportDiv").OpenDiv3();
}
//关闭批量更新Div
function closeCalTemplateImportDiv(){
	$("#calTemplateImportDiv").CloseDiv3();
}
//算法模板下载
function calTemplateDownLoad(){
	window.location.href='<%=path%>/product/feeRate/newLifeDownLoad?calDefId='+calDefIdAll;
}
//计算方式保存
function saveCal(){
	var radio = $("input[name='radioProPlan']:checked");
	var rationId = radio.parent().parent().children("td:eq(5)").html();//保障计划Id
	var tradPlanCode=$("#tradPlanCode").val();//产品号
	var covIdAll=$("#covIdAll").val();//保费计算方式
	var tradPlanCodeFlag=$("#tradPlanCodeFlag").val();//险种
	var fixed=$("#fixed").val();
    var fixedConds = '';// [{"A1":"55"}, {"A2":"66"}]
	var codeCname='';
	var arr='';
	//固定保费
	if(calDefIdAll=="000000000801"||calDefIdAll=="000000000809"||calDefIdAll=="000000000814"){
		if(fixed==''){
			$.message("error","请输入保费");
			return;
		}
		//按天区间
	}else if(calDefIdAll=="000000000802"){
		var arr1 = new Array();
		for(var i = 1; i <= count2; i++) {
			var cond1=$('#cond1'+i).val();
			if(""==$.trim(cond1)){
				$.message("error","请输入最小天数");
				return;
			}
			var cond2=$('#cond2'+i).val();
			if(""==$.trim(cond2)){
				$.message("error","请输入最大天数");
				return;
			}
			if(parseInt($.trim(cond2))<parseInt($.trim(cond1))){
				$.message("error","最大天数不能小于最小天数");
				return;
			}
			if(parseInt($.trim(cond2))<smallYeay||parseInt($.trim(cond2))>maxYeay){
				$.message("error","按产品配置最大天数应在"+smallYeay+"与"+maxYeay+"之间");
				return;
			}
			if(parseInt($.trim(cond1))<smallYeay||parseInt($.trim(cond1))>maxYeay){
				$.message("error","按产品配置最小天数应在"+smallYeay+"与"+maxYeay+"之间");
				return;
			}
			var fixed=$('#fixed'+i).val();
			if(""==$.trim(fixed)){
				$.message("error","请输入保费");
				return;
			}
			var o=new Object();
			o.preRate=fixed;
			o.cond1=cond1;
			o.cond2=cond2;
			arr1.push(o);
		}
		/* arr=JSON.stringify(arr1); */
	}else if(calDefIdAll=="000000000803"){
		cond7=$('#cond7').val();
		if(fixed==''){
			$.message("error","请输入保费");
			return;
		}
		if(cond7==0){
			$.message("error","请选择麻醉类型");
			return;
		}
	}else if(calDefIdAll=="000000000804"){
		var arr1 = new Array();
		for (var i = 1; i <= count4; i++) {
			var preRate=$('#premRate'+i).val();
			if(preRate==''){
				$.message("error","请输入费率");
				return;
			}
			var cond5=$('#cond5'+i).val();
			var cond1=$('#cond1'+i).val();
			var o=new Object();
			o.preRate=preRate;
			o.cond1=cond1;
			o.cond5=cond5;
			arr1.push(o);
		}
		/* arr=JSON.stringify(arr1); */
	}else if(calDefIdAll=="000000000805"){
		var arr1 = new Array();
		for(var i = 1; i <= count; i++) {
			var miny=$('#miny'+i).val();
			if(""==$.trim(miny)){
				$.message("error","请输入最小年份");
				return;
			}
			var maxy=$('#maxy'+i).val();
			if(""==$.trim(maxy)){
				$.message("error","请输入最大年份");
				return;
			}
			if(parseInt($.trim(maxy))<parseInt($.trim(miny))){
				$.message("error","最大年份不能小于最小年份");
				return;
			}
			if(parseInt($.trim(maxy))<smallYeay||parseInt($.trim(maxy))>maxYeay){
				$.message("error","按产品配置最大年份应在"+smallYeay+"与"+maxYeay+"之间");
				return;
			}
			if(parseInt($.trim(miny))<smallYeay||parseInt($.trim(miny))>maxYeay){
				$.message("error","按产品配置最小年份应在"+smallYeay+"与"+maxYeay+"之间");
				return;
			}
			var dept=$('#dept'+i).val();
			if(""==$.trim(dept)){
				$.message("error","请输入部门");
				return;
			}
			var fixed=$('#fixed'+i).val();
			if(""==$.trim(fixed)){
				$.message("error","请输入保费");
				return;
			}
			var o=new Object();
			o.preRate=fixed;
			o.miny=miny;
			o.maxy=maxy;
			arr1.push(o);
		}
	/* 	arr=JSON.stringify(arr1); */
	}else if(calDefIdAll=="000000000806"||calDefIdAll=="000000000815"){
		var arr1 = new Array();
		//获取所有信息
		for(var i = 1; i <= count1; i++) {
			//使用类型
			var cond7=$('#cond7'+i).val();
			if(cond7==""){
				$.message("error","请选择使用性质");
				return;
			}
			//车辆类型
			var cond8=$('#cond8'+i).val();
			//座位数
			var cond1=$('#cond1'+i).val();
			if(""==$.trim(cond1)){
				if(calDefIdAll=="000000000815"){
					$.message("error","请输入座位数");
					return;
				}
				cond1='0';
			}
			//保费
			var fixed=$('#fixed'+i).val();
			if(""==$.trim(fixed)){
				$.message("error","请输入保费");
				return;
			}
			var o=new Object();
			o.cond7=cond7;
			o.cond8=cond8;
			o.cond1=cond1;
			o.fixed=fixed;
			arr1.push(o);
		}
		/* arr=JSON.stringify(arr1); */
	}else if(calDefIdAll=="000000000807"){
		var arr1 = new Array();
		for(var i = 1; i <= count3; i++) {
			var cond11=$('#cond11'+i).val();
			if(""==$.trim(cond11)){
				$.message("error","请输入最小年龄");
				return;
			}
			var cond12=$('#cond12'+i).val();
			if(""==$.trim(cond12)){
				$.message("error","请输入最大年龄");
				return;
			}
			if(parseInt($.trim(cond12))<parseInt($.trim(cond11))){
				$.message("error","最大年龄不能小于最小年龄");
				return;
			}
			var fixed=$('#fixed'+i).val();
			if(""==$.trim(fixed)){
				$.message("error","请输入保费");
				return;
			}
			var o=new Object();
			o.preRate=fixed;
			o.cond11=cond11;
			o.cond12=cond12;
			arr1.push(o);
		}
	/* 	arr=JSON.stringify(arr1); */
	}else if(calDefIdAll=="000000000810"){
		var arr1 = new Array();
		//获取所有信息
		for(var i = 1; i <= count1; i++) {
			//使用类型
			var cond7=$('#cond7'+i).val();
			if(cond7==""){
				$.message("error","请选择使用性质");
				return;
			}
			//车辆类型
			var cond8=$('#cond8'+i).val();
			//座位数下限
			var cond1=$('#cond1'+i).val();
			if(""==$.trim(cond1)){
				cond1='0';
			}
			//座位数上限
			var cond2=$('#cond2'+i).val();
			//保费
			var fixed=$('#fixed'+i).val();
			if(""==$.trim(fixed)){
				$.message("error","请输入保费");
				return;
			}
			var o=new Object();
			o.cond7=cond7;
			o.cond8=cond8;
			o.cond1=cond1;
			o.cond2=cond2;
			o.fixed=fixed;
			arr1.push(o);
		}
	/* 	arr=JSON.stringify(arr1); */
	}else if(calDefIdAll=="000000000813"||calDefIdAll=="000000000812"){
		var arr1 = new Array();
		for (var i = 1; i <= count5; i++) {
			var preRate=$('#premRate'+i).val();
			if(preRate==''){
				$.message("error","请输入保费");
				return;
			}
			var cond1=$('#cond1'+i).val();
			if(cond1==''){
				$.message("error","请输入天数/月数/年数");
				return;
			}
			var o=new Object();
			o.preRate=preRate;
			o.cond1=cond1;
			arr1.push(o);
		}
	/* 	arr=JSON.stringify(arr1); */
	}else if (calDefIdAll=="000000000877"){
		var arr1 = new Array();
		for (var i = 1; i <= count1; i++) {
			var preRate=$('#premRate'+i).val();
			if(preRate==''){
				$.message("error","请输入保费");
				return;
			}
			var cond7=$('#cond7'+i).val();
			if(cond7==''){
				$.message("error","请输入机构");
				return;
			}
			var cond1=$('#cond1'+i).val();
			var cond3=$('#cond3'+i).val();
			var cond2=$('#cond2'+i).val();
			var cond10=$("#cond10"+i).val();
			var o=new Object();
			o.preRate=preRate;
			o.cond7=cond7;
			o.cond3=cond3;
			o.cond2=cond2;
			o.cond1=cond1;
			o.cond10=cond10;
			arr1.push(o);
		}
	}else if(calDefIdAll=="000000000884"){
		var arr1 = new Array();

		for(var i = 1; i <= count3; i++) {
			var isByStaged=$('#isByStaged'+i).val();
			var cond11=$('#cond11'+i).val();
			if(""==$.trim(cond11)){
				$.message("error","请输入最小年龄");
				return;
			}
			var cond12=$('#cond12'+i).val();
			if(""==$.trim(cond12)){
				$.message("error","请输入最大年龄");
				return;
			}
			if(parseInt($.trim(cond12))<parseInt($.trim(cond11))){
				$.message("error","最大年龄不能小于最小年龄");
				return;
			}
			var o=new Object();
			o.isByStaged=isByStaged;
			o.cond11=cond11;
			o.cond12=cond12;
			if ($('#isByStaged'+i).val()=='0') {
				var fixed=$('#fixed'+i).val();
				if(""==$.trim(fixed)){
					$.message("error","请输入保费");
					return;
				}
				o.preRate=fixed;
			}else{
				var monthMap = new Map();
				for(num=1;num<13;num++){
					var month = $('#month'+num+"-"+i).val();
					if(""==$.trim(month)){$.message("error","请输入第"+num+"期保费");return;}
					monthMap.put("month"+num,month);
				}
				o.monthMap=monthMap;
			}
			arr1.push(o);
		}
	}else if(calDefIdAll=="000000000885"){
		var arr1 = new Array();
		for (var i = 1; i < 3; i++) {
			var isByStaged=$('#isByStaged'+i).val();
			var o=new Object();
			o.isByStaged=isByStaged;
			if ($('#isByStaged'+i).val()=='0') {
				o.preRate=$('#fixed').val();;
			}else{
				var monthMap = new Map();
				for(num=1;num<13;num++){
					var month = $('#month'+num).val();
					monthMap.put("month"+num,month);
				}
				o.monthMap=monthMap;
			}

			arr1.push(o);
		}
	} else if(calDefIdAll == '000000000886' || calDefIdAll == '000000000887'){
        var cond7s = $('.cond7');
        var fixeds = $('.fixed');
        var cond7 = '';
        var fixed = '';
        var allNull = true;
        fixedConds = '{'
        for (var i = 0; i < fixeds.length; i++) {
            cond7 = cond7s[i].id;
            fixed = fixeds[i].value;
            if(fixed === '' || fixed === null || fixed === undefined) {
                continue;
            }
            allNull = false;
            if (!isNumber(fixed)){
                $.message("error","请正确输入数字");
                return;
            }
            fixedConds += '"' + cond7 + '":"' + fixed + '",';
        }
        fixedConds = fixedConds.substring(0, fixedConds.length-1);
        fixedConds += '}';
        tradPlanCode = tradPlanCodeAll;
        if(allNull){
            $.message("error","请正确输入保费");
            return;
        }
    }
	// 判断是否是数字
    function isNumber(val) {
        var regPos = /^\d+(\.\d+)?$/; //非负浮点数
        var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
        if(regPos.test(val) || regNeg.test(val)) {
            return true;
        } else {
            return false;
        }
    }
	arr=JSON.stringify(arr1);
	$.openLoading();
 	$.ajax({
		url : "product/feeRate/saveCall1",
		type : "POST",
		async : false,
		dataType:'json',
		data:{prodCode:tradPlanCode,riskCode:tradPlanCodeFlag,covId:covIdAll,fixed:fixed,fixedConds:fixedConds ,callId:calDefIdAll,cond7:cond7,days:arr,rationId:rationId},
		success:function(data){
			if(data.result){
				$.message("success","保存成功");
				$("#editCalDiv").CloseDiv2();
				count=1;
				count3=1;
				count4=1;
				count5=1;
			}else{
				if(data.massager){
					$.message("error",data.massager);
				}else{
					$.message("error","操作失败,请联系管理员");
				}
			}
		}
	});
	$.closeLoading();
}
/**算法配置弹出算法div*/
function checkOpenCalDiv1(){
	 count=1;
	 count1=1;
	 count2=1;
	 count4=1;
	 count5=1;
	var radioCov = $("input[name='radioCov']:checked");
	var radio = $("input[name='radioProPlan']:checked");
	if(radioCov.val() == undefined) {
		$.message("error","请选择一个责任");
		return;
	}
	var tradPlanCode = radioCov.parent().parent().children("td:eq(1)").html();// 险种代码代码
	tradPlanCodeFlag=tradPlanCode;
	var coveCode = radioCov.parent().parent().children("td:eq(2)").html();// 责任代码
	covIdAll=coveCode;
	var calId = radioCov.parent().parent().children("td:eq(7)").html();// 责任代码
	//保障计划Id
	var rationId = radio.parent().parent().children("td:eq(5)").html();//保障计划编号
	calDefIdAll=calId;

	if(calDefIdAll == '000000000877'){
		return;
	}

	//查询已配置算法
	 if(calDefIdAll=="000000000801"||calDefIdAll=="000000000802"||calDefIdAll=="000000000803"||calDefIdAll=="000000000804"||calDefIdAll=="000000000806"||calDefIdAll=="000000000807"||calDefIdAll=="000000000809"||calDefIdAll=="000000000810"||calDefIdAll=="000000000812"||calDefIdAll=="000000000813"||calDefIdAll=="000000000814"||calDefIdAll=="000000000815"||calDefIdAll=="000000000877"||calDefIdAll=="000000000884"||calDefIdAll=="000000000885" || calDefIdAll == "000000000886" || calDefIdAll == "000000000887"){
		$.openLoading();
		 $.ajax({
			url : "product/feeRate/getCall",
			type : "POST",
			async : false,
			dataType:'json',
			data:{prodCode:tradPlanCodeAll,riskCode:tradPlanCodeFlag,covId:covIdAll,calDefIdAll:calDefIdAll,calDefIdAll:calDefIdAll,rationId:rationId},
			success:function(data) {
				var tableHtml=getTableHtml(data);
				if(tableHtml == undefined) {
					$.message("error","该险种算法配置有误，请检查数据库中对应的算法表或联系管理员");
					return;
				}
				var calTd = $('#calTd');
				calTd.html('');
				calTd.prepend(tableHtml);
				buttons();
				if(calDefIdAll == '000000000803'){
                    if(data.calls.length==1&&data.calls[0].cond7!=null&&data.calls[0].cond7.indexOf("C")!=-1){
						$('#cond7').val(data.calls[0].cond7);
						$('#fixed').val(data.calls[0].premRate)
					}
				}
				if ((calDefIdAll == '000000000886' || calDefIdAll == '000000000887') && data.calls.length >= 1) {
                        for (var i = 0; i < data.calls.length; i++) {
                            var call = data.calls[i];
                            $('#fixed_' + call.cond7).val(call.premRate);
                        }
                }
				if(calDefIdAll == '000000000806'||calDefIdAll == '000000000810'||calDefIdAll == '000000000815'){
					if(data.calls.length>0){
						count1=data.calls.length;
						for(var i=0;i<data.calls.length;i++){
							$('#cond1'+(i+1)).val(data.calls[i].cond1);
							if(calDefIdAll == '000000000810'){
								$('#cond2'+(i+1)).val(data.calls[i].cond2);
							}
							$('#cond7'+(i+1)).val(data.calls[i].cond7);
							$('#cond7'+(i+1)).parent("td:eq(0)").find("input[id='natureText']").val(data.calls[i].chnname);
							$('#cond8'+(i+1)).val(data.calls[i].cond8);
							$('#fixed'+(i+1)).val(data.calls[i].premRate);
						}
					}
				}
				if(calDefIdAll == '000000000877'){
					if(data.calls.length>0){
						count1=data.calls.length;
						for(var i=0;i<data.calls.length;i++){
							$('#cond3'+(i+1)).val(data.calls[i].cond3);
							$('#cond10'+(i+1)).val(data.calls[i].cond10);
						}
					}
				}
				$.closeLoading();
				if(data.remark==null){
					data.remark='无';
				}
				$('#remark').html("说明："+data.remark);
				$('#editCalDiv').OpenDiv2();
				if(calDefIdAll == '000000000877'){
					$('#editCalDiv').css("top", "67px");
					$('#calDDD').css('height','300px');
				}
			}
		});
	 }else{
		 $.message("error","暂不支持，请到数据库进行配置或联系管理员");
		return;
	 }
}
/**算法各个算法按钮处理**/
function buttons(){
	/**多行不含导入*/
	if(calDefIdAll == '000000000805'||calDefIdAll == '000000000806'||calDefIdAll == '000000000807'||calDefIdAll == '000000000804'||calDefIdAll == '000000000815'||calDefIdAll == '000000000810'||calDefIdAll == '000000000884'){
		$("#buttonHidden1").hide();
		$("#buttonHidden2").hide();
		$("#buttonHidden05").show();
		$("#buttonHidden02").hide();
	/**多行含导入*/
	}else if(calDefIdAll == '000000000802'||calDefIdAll == '000000000812'||calDefIdAll == '000000000813'||calDefIdAll == '000000000877'){
		$("#buttonHidden1").hide();
		$("#buttonHidden2").hide();
		$("#buttonHidden05").hide();
		$("#buttonHidden02").show();
	}
	else{
		//不需要导入导出
		$("#buttonHidden1").show();
		$("#buttonHidden2").hide();
		$("#buttonHidden05").hide();
		$("#buttonHidden02").hide();
	}
}
/**打开算法div时创建table*/
function getTableHtml(data) {
	var tableStr = "<input type='hidden' id='tradPlanCode' value='" + tradPlanCodeAll + "' /><input type='hidden' id='tradPlanCodeFlag' value='" + tradPlanCodeFlag + "' /><input type='hidden' id='covIdAll' value='" + covIdAll + "' />";
	//责任固定保费算法
	if(calDefIdAll=="000000000801"||calDefIdAll=='000000000809'||calDefIdAll=='000000000814'){
		if(data.calls.length == 1) {
			tableStr += "<table id='calTable' class='content_table_1'><tbody><tr><td><span>保费：</span><input id='fixed' name='fixed' value='" + data.calls[0].premRate + "' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr></tbody></table>";
		} else{
			tableStr += "<table id='calTable' class='content_table_1'><tbody><tr><td><span>保费：</span><input id='fixed' name='fixed' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr></tbody></table>";
 		}
		if(calDefIdAll=='000000000809'){
			$('#titleDiv').html('每天保费固定乘以天数算法');// 设置标题
		}else if (calDefIdAll=='000000000801'){
			$('#titleDiv').html('责任固定保费算法');// 设置标题
		}else if (calDefIdAll=='000000000814'){
			$('#titleDiv').html('责任固定保费算法-共享保费');// 设置标题
		}
		$('#calDDD').css('height','');
		return tableStr;
		//责任按天区间算法
	}else if(calDefIdAll=="000000000802"){
		$('#titleDiv').html('责任按天区间算法');// 设置标题
		smallYeay = data.tradProd.minDays;
		maxYeay = data.tradProd.maxDays;
		if(data.calls.length>0&&data.calls[0].cond1!=null&&data.calls[0].cond2!=null){
			tableStr +=adddept5(data);
		}else{
			tableStr += "<table id='calTable' class='content_table_1'><tbody><tr id='count1'>"
				+"<td width='20px'>1</td>"
				+"<td>最小天数：<input id='cond11' name='cond11' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
				+"<td>最大天数：<input id='cond21' name='cond21' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
				+"<td><span>保费：</span><input id='fixed1' name='fixed1' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr></tbody></table>";
			$('#calDDD').css('height','');
		}
		return tableStr;
	}else if(calDefIdAll=="000000000803"){
		var codeCnames=data.codeCnames;
		tableStr += "<table id='calTable' class='content_table_1'><tbody><tr>"
		+"<td>麻醉类型：</td>"
		  +"<td>"
		   		+"<select id='cond7' name='cond7'>"
		   		+"<option value='0'>请选择</option>"
		   		for (var i = 0; i < codeCnames.length; i++) {
		   			tableStr += "<option value='"+codeCnames[i].code+"'>"+codeCnames[i].codeName+"</option>"
				}
		   		tableStr +="</select>"
		   				+"</td>"
					+"<td><span>保费：</span><input id='fixed' name='fixed' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr></tbody></table>";
				$('#titleDiv').html('责任按麻醉类型算保费');// 设置标题
				$('#calDDD').css('height','');
				return tableStr;
	//责任保额算法
	}else if(calDefIdAll=="000000000804"){
		$('#titleDiv').html('责任保额算法');// 设置标题
		if(data.calls.length>0&&data.calls[0].premRate!=null){
			tableStr +=adddept7(data);
		}else{
			tableStr += "<table id='calTable' class='content_table_1'><tbody><tr id='count"+count4+"'>"
			+"<td width='20px'>"+count4+"</td>"
			+"<td>费率：<input id='premRate"+count4+"' name='premRate"+count4+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'><span class='red'>*</span></td>"
			+"<td>系数：<input id='cond5"+count4+"' name='cond5"+count4+"' value='1' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保险期间：</span><input id='cond1"+count4+"' name='cond1"+count4+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr></tbody></table>";
			$('#calDDD').css('height','');
		}
		return tableStr;
	//责任贷款金额保费算法(非通用算法界面不显示)
	}else if(calDefIdAll=="000000000805"){
		smallYeay = data.tradProd.minDays;
		maxYeay = data.tradProd.maxDays;
		$('#titleDiv').html('责任贷款金额保费算法');// 设置标题
		if(data.calls.length>0&&data.calls[0].days!=null&&data.calls[0].codeCname!=null){
			tableStr +=adddept1(data);
		}else{
		tableStr += "<table id='calTable' class='content_table_1'><tbody><tr id='count1'>"
			+"<td width='20px'>"+count+"</td>"
			+"<td>最小年份：<input id='miny1' name='miny1' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td>最大年份：<input id='maxy1' name='maxy1' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td>部门：<input id='dept1' name='dept1' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed1' name='fixed1' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr></tbody></table>";
		$('#calDDD').css('height','');
		}
		return tableStr;
	}else if(calDefIdAll=="000000000806"||calDefIdAll=="000000000815"){
		carType.put("carType",data.carType);
		if(calDefIdAll=="000000000806"){
			$('#titleDiv').html('驾乘险责任算法');// 设置标题
		}else  if (calDefIdAll=="000000000815"){
			$('#titleDiv').html('驾乘险算法-共享保额');// 设置标题
		}
		if(data.calls.length>0){
			tableStr += "<table id='calTable' class='content_table_1'><tbody>"
				tableStr +=	'<tr>'+
				'<td align="center" style="width:36%">车辆使用性质</td>'+
				'<td align="center" style="width:10%">车辆类型</td>'+
				'<td align="center" style="width:27%">座位数</td>'+
				'<td align="center" style="width:20%">保费</td>'+
				'</tr>'
				for(var i=1;i<=data.calls.length;i++){
					tableStr +=cartable(i);
				}
				tableStr +="</tbody></table>";
		}else{
			tableStr += "<table id='calTable' class='content_table_1'><tbody>"
				tableStr +=	'<tr>'+
				'<td align="center" style="width:36%">车辆使用性质</td>'+
				'<td align="center" style="width:10%">车辆类型</td>'+
				'<td align="center" style="width:27%">座位数</td>'+
				'<td align="center" style="width:20%">保费</td>'+
				'</tr>'
			+cartable(1)+"</tbody></table>";
			$('#calDDD').css('height','');
		}
		return tableStr;

	}else if(calDefIdAll=="000000000807"){
		$('#titleDiv').html('责任按年龄区间算法');// 设置标题
		if(data.calls.length>0){
			tableStr +=adddept3(data);
		}else{
		tableStr += "<table id='calTable' class='content_table_1'><tbody><tr id='count1'>"
			+"<td width='20px'>"+count3+"</td>"
			+"<td>最小年龄：<input id='cond111' name='cond111' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td>最大年龄：<input id='cond121' name='cond121' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed1' name='fixed1' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr></tbody></table>";
		$('#calDDD').css('height','');
		}
		return tableStr;
	}else if(calDefIdAll=="000000000810"){
		carType.put("carType",data.carType);
		$('#titleDiv').html('驾乘险座位区间算法');// 设置标题
		if(data.calls.length>0){
			tableStr += "<table id='calTable' class='content_table_1'><tbody>"
				tableStr +=	'<tr>'+
				'<td align="center" style="width:36%">车辆使用性质</td>'+
				'<td align="center" style="width:10%">车辆类型</td>'+
				'<td align="center" style="width:15%">座位数下限</td>'+
				'<td align="center" style="width:15%">座位数上限</td>'+
				'<td align="center" style="width:20%">保费</td>'+
				'</tr>'
				for(var i=1;i<=data.calls.length;i++){
					tableStr +=cartable1(i);
				}
				tableStr +="</tbody></table>";
		}else{
			tableStr += "<table id='calTable' class='content_table_1'><tbody>"
				tableStr +=	'<tr>'+
				'<td align="center" style="width:36%">车辆使用性质</td>'+
				'<td align="center" style="width:10%">车辆类型</td>'+
				'<td align="center" style="width:15%">座位数上限</td>'+
				'<td align="center" style="width:15%">座位数下限</td>'+
				'<td align="center" style="width:20%">保费</td>'+
				'</tr>'
			+cartable1(1)+"</tbody></table>";
			$('#calDDD').css('height','');
		}
		return tableStr;

	}
	else if(calDefIdAll=="000000000813"||calDefIdAll=="000000000812"){
		$('#titleDiv').html('责任按天/按月算法');// 设置标题
		if(data.calls.length>0&&data.calls[0].premRate!=null){
			tableStr +=adddept9(data);
		}else{
			tableStr += "<table id='calTable' class='content_table_1'><tbody><tr id='count"+count5+"'>"
			+"<td width='20px'>"+count5+"</td>"
			+"<td>保费：<input id='premRate"+count5+"' name='premRate"+count5+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'><span class='red'>*</span></td>"
			+"<td><span>天数/月数/年数：</span><input id='cond1"+count5+"' name='cond1"+count5+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr></tbody></table>";
			$('#calDDD').css('height','');
		}
		return tableStr;
	//责任贷款金额保费算法
	}
	else if(calDefIdAll=="000000000877"){
		var callTypes=data.callTypes;
		carType.put("callTypes",data.callTypes);
		$('#titleDiv').html('信保通（新疆）算法');// 设置标题
		if(data.calls.length>0&&data.calls[0].premRate!=null){
			tableStr +=adddept12(data);
		}else{
			tableStr += "<table id='calTable' class='content_table_1'><tbody><tr id='count"+count1+"'>"
			+"<td width='5%'>"+count1+"</td>"
			+"<td width='20%'>算法规则：<select id='cond3"+count1+"' onchange='callTypeChange("+count1+")'  style='width:100px'>"
			for (var i = 0; i < callTypes.length; i++) {
	   			tableStr += "<option value='"+callTypes[i].code+"'>"+callTypes[i].codeName+"</option>"
			}
			tableStr+="</select></td>"
			+"<td width='15%'>机构：<input id='cond7"+count1+"' name='cond7"+count1+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:100px'><span class='red'>*</span></td>"
			+"<td width='15%'>费率：<input id='premRate"+count1+"' name='premRate"+count1+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:80px'>‰</td>"
			+"<td width='15%'><span>最小区间：</span><input id='cond1"+(count1)+"' name='cond1"+(count1)+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:50px' disabled='disabled' ></td>"
			+"<td width='15%'><span>最大区间：</span><input id='cond2"+(count1)+"' name='cond2"+(count1)+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:50px' disabled='disabled' ></td>"
			+"<td width='15%'><span>需求类型：</span><select id='cond10"+count1+"'><option value='1'>信保通</option><option value='0'>农贷通</option></select></td></tr></tbody></table>";
		}
		return tableStr;
	//责任贷款金额保费算法
	}
	//责任按年龄区间-分期算法
	else if(calDefIdAll=="000000000884"){
		$('#titleDiv').html('责任按年龄区间-分期算法');// 设置标题
		if(data.calls.length>0){
			tableStr +=adddept13(data);
		}else{
		tableStr += "<table id='calTable' class='content_table_1'><tbody><tr id='count1'>"
			+"<td width='20px'>"+count3+"</td>"
			+"<td>是否分期：<select id='isByStaged1' onchange='isByStagedChange("+count3+")' style='width:50px'><option value='0' selected='selected'>否</option><option value='1'>是</option></select></td>"
			+"<td width='150px'>最小年龄：<input id='cond111' name='cond111' value='' style='width:50px' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td width='150px'>最大年龄：<input id='cond121' name='cond121' value='' style='width:50px' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed"+count3+"' name='fixed"+count3+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>"
			for (var i = 1; i < 13; i++) {
				tableStr += "<input id='month"+i+"-"+count3+"' name='stageFixed"+count3+"' style='display:none;width:40px;margin-right:5px' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>"
			}
			tableStr += "</td></tr></tbody></table>"
		$('#calDDD').css('height','');
		}
		return tableStr;
	}
	//责任固定保费-分期算法
	else if(calDefIdAll=="000000000885"){
		var callTypes=data.callTypes;
		carType.put("callTypes",data.callTypes);
		$('#titleDiv').html('责任固定保费-分期算法');// 设置标题
		if(data.calls.length>0&&data.calls[0].premRate!=null){
			tableStr +=adddept14(data);
		}else{
			tableStr += "<table id='calTable' class='content_table_1'><tbody>"
			+"<td>是否分期：<select id='isByStaged1' style='width:50px'><option value='0' selected='selected'>否</option></select></td>"
			+"<td><span>保费：</span><input id='fixed' name='fixed' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>"
			+"<tr><td>是否分期：<select id='isByStaged2' style='width:50px'><option value='1' selected='selected'>是</option></select></td>"
			+"<td><span>保费：</span>"
			for (var i = 1; i < 13; i++) {
				tableStr += "<input id='month"+i+"' name='stageFixed' style='width:40px;margin-right:5px' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>"
			}
			tableStr += "</td></tr>"
		}
		return tableStr;
	//责任贷款金额保费算法
	}
	// 麻醉类型算法
	else if(calDefIdAll === '000000000887'){
        var codeCnames=data.codeCnames;
        tableStr += "<table id = 'calTable' class='content_table_1'><tbody><tr>"
            + "<td>麻醉类型：</td><td>保费</td></tr>";
        for (var i = 0; i < codeCnames.length; i++){
            var cond7 = codeCnames[i].code;
            var CodeName = codeCnames[i].codeName;
            tableStr += "<tr><td><span id='" + cond7 + "' class='cond7'>" + (CodeName ? CodeName : '') + "</span></td>"
                + "<td><input id='fixed_" + cond7 + "' name='fixed' class='fixed' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'/></td></tr>";
        }
        tableStr += "</tbody></table>";
        $('#titleDiv').html('麻醉类型算法');// 设置标题
        $('#calDDD').css('height','');
        return tableStr;
    }
	// 手术类型算法
    else if (calDefIdAll === '000000000886') {
        var opsTypes=data.opsTypes;
        tableStr += "<table id = 'calTable' class='content_table_1'><tbody><tr>"
            + "<td>手术类型：</td><td>保费</td></tr>";
        for (var i = 0; i < opsTypes.length; i++){
            var cond7 = opsTypes[i].code;
            var CodeName = opsTypes[i].codeName;
            tableStr += "<tr><td><span id='" + cond7 + "' class='cond7'>" + (CodeName ? CodeName : '') + "</span></td>"
                + "<td><input id='fixed_" + cond7 + "' name='fixed' class='fixed' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'/></td></tr>";
        }
        tableStr += "</tbody></table>";
        $('#titleDiv').html('手术类型算法');// 设置标题
        $('#calDDD').css('height','');
        return tableStr;
    }
}



function clearNoNum1(obj){
	  obj.value = obj.value.replace(/[^\d]/g,"");
}
function openUseNatureDiv(obj) {
	$.openLoading();
	trObj = obj;
	$.ajax({
		url : "<%=path%>/product/feeRate/queryUseNatureByPage1",
		type : 'POST',
		async : false,
		dataType : 'json',
		data : {pageIndex:1},
		success:function(configPage) {
			$.closeLoading();
			if($.validate(configPage)) {
				return;
			}
			var checkboxObj ="<input name='naturearr' type='checkbox'>";
			var fieldNames = "codeName,code";
			var tableContent = creatTable1(fieldNames,configPage,checkboxObj,null);
			var tableObj = $("#useNatureDivTable");
			tableObj.find("tbody").remove();
			tableObj.append(tableContent);
			var useID=$(trObj).parent("td:eq(0)").find("input[name='useNature']").val();
			$("input[name='naturearr']").each(function(){
				var id = $(this).parent().parent().children("td:eq(2)").html();
				var name = $(this).parent().parent().children("td:eq(1)").html();
				if(useID!=null){
					if(useID.indexOf(id)!=-1){
						map1.put(id,name);
						$(this).prop("checked",true);
						$(this).parent().parent().addClass("table_highlighter");
					}
				}
			});

			checkAllForUseNature();
			bindradioSSS();
			$('#useNatureDiv').OpenDiv3();
		}
	});
}
var map1 = new Map();
//绑定单选按钮事件，选中某个单选按钮，该按钮所在行高亮显示
function bindradioSSS() {
	$("input[name='naturearr']").click(function() {
		var id = $(this).parent().parent().children("td:eq(2)").html();
		var name = $(this).parent().parent().children("td:eq(1)").html();
		if($(this).prop("checked")) {//选中
			$(this).parent().parent().addClass("table_highlighter");
			map1.put(id, name);
			checkAllForUseNature();
		} else {//取消选中
			$(this).parent().parent().removeClass("table_highlighter");
			$(this).prop("checked",false);
			map1.remove(id);
			$("#useNatureCheckAll").prop("checked",false);
		}
	});
	$("#useNatureCheckAll").click(function() {
		if($(this).prop("checked")){//选中
			$("#useNatureDivTable tbody tr").each(function() {
				$(this).find("input[name='naturearr']").prop("checked",true);
				$(this).addClass("table_highlighter");
				var id = $(this).children("td:eq(2)").html();
				var name = $(this).children("td:eq(1)").html();
				map1.put(id, name);
			});
		} else {//取消选中
			$("#useNatureDivTable tbody tr").each(function() {
				$(this).removeClass("table_highlighter");
				$(this).find("input[name='naturearr']").prop("checked",false);
				var id = $(this).children(" td:eq(2)").html();
				map1.remove(id);
			});
		}
	});
}
//保存车辆使用性质
function saveUseNature() {
	var natureNames = map1.values();// 已选择的车辆性质name （数组）
	var natureValues = map1.keys();// 已选择的车辆性质code （数组）
	var useNature = $(trObj).parent("td:eq(0)").find("input[id='natureText']");
	useNature.val(natureNames);
	useNature.attr('title', natureNames)
	var natureValueStr = '';
	if(natureValues.toString().indexOf(",") != -1) {
		natureValueStr = ',' + natureValues.toString() + ',';
	} else {
		natureValueStr = natureValues.toString();
	}
	var useNatureValue = $(trObj).parent("td:eq(0)").find("input[name='useNature']").val(natureValueStr);
	closeUseNatureDiv('useNatureDiv');
}

// 车辆使用性质窗口关闭
function closeUseNatureDiv(obj) {
	map1.clear();
	$("#useNatureDivTable").find("tr").each(function() {
		$(this).children("td:eq(0)").find("input[name='naturearr']").prop("checked",false);
	});
    $("#"+obj).CloseDiv3();
}

//全选操作
function checkAllForUseNature() {
	var flag = false;
	$("#useNatureDivTable tbody").find("tr").each(function() {
		if(!$(this).children("td:eq(0)").find("input[name='naturearr']").prop("checked")) {
			flag = true;//如果有未选择的
		}
	});
	if(flag) {
		$("#useNatureCheckAll").prop("checked",false);
	} else {
		$("#useNatureCheckAll").prop("checked",true);
	}
}
//算法添加行--------------------------------------
//创建table
function adddept(){
	if(calDefIdAll == '000000000806'||calDefIdAll == '000000000815'){
		adddept2();
		return;
	}
	if(calDefIdAll == '000000000802'){
		adddept4();
		return;
	}
	if(calDefIdAll == '000000000804'){
		adddept6();
		return;
	}
	if(calDefIdAll == '000000000813'||calDefIdAll == '000000000812'){
		adddept8();
		return;
	}
	/**驾乘险3*/
	if(calDefIdAll == '000000000810'){
		adddept10();
		return;
	}
	/**新疆信保通*/
	if(calDefIdAll == '000000000877'){
		adddept11();
		return;
	}
	count++;
	count3++
	$.openLoading();
	var tableStr = "";
	if(calDefIdAll == '000000000805'){
		tableStr += "<tr id='count"+count+"'>"
		+"<td width='20px'>"+count+"</td>"
		+"<td>最小年份：<input id='miny"+count+"' name='miny"+count+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
		+"<td>最大年份：<input id='maxy"+count+"' name='maxy"+count+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
		+"<td>部门：<input id='dept"+count+"' name='dept"+count+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
		+"<td><span>保费：</span><input id='fixed"+count+"' name='fixed"+count+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	}else if(calDefIdAll == '000000000807'){
		tableStr += "<tr id='count"+count3+"'>"
		+"<td width='20px'>"+count3+"</td>"
		+"<td>最小年龄：<input id='cond11"+count3+"' name='cond11"+count3+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
		+"<td>最大年龄：<input id='cond12"+count3+"' name='cond12"+count3+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
		+"<td><span>保费：</span><input id='fixed"+count3+"' name='fixed"+count3+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	}else if(calDefIdAll == '000000000884'){
		tableStr += "<tr id='count"+count3+"'>"
		+"<td width='20px'>"+count3+"</td>"
		+"<td>是否分期：<select id='isByStaged"+count3+"' onchange='isByStagedChange("+count3+")' style='width:50px'><option value='0' selected='selected'>否</option><option value='1'>是</option></select></td>"
		+"<td width='40px'>最小年龄：<input id='cond11"+count3+"' name='cond11"+count3+"' style='width:50px' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
		+"<td width='40px'>最大年龄：<input id='cond12"+count3+"' name='cond12"+count3+"' style='width:50px' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
		+"<td><span>保费：</span><input id='fixed"+count3+"' name='fixed"+count3+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>"
		for (var i = 1; i < 13; i++) {
			tableStr += "<input id='month"+i+"-"+count3+"' name='stageFixed"+count3+"' style='display:none;width:40px;margin-right:5px' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>"
		}
		tableStr += "</td></tr>";
	}
	var calTd = $('#calTable');
	calTd.append(tableStr);
	buttons();
	if(calDefIdAll == '000000000803'){
		if(data.calls[0].codeCname.indexOf("C")!=-1){
			$('#cond7').val(data.calls[0].cond7);
			$('#fixed').val(data.calls[0].premRate)
		}
	}
	$.closeLoading();
	if(count3=='10'){
		$('#calDDD').css('height','300px');
		$('#editCalDiv').OpenDiv2();
	}

}

//是否分期修改
function isByStagedChange(id){
	var isByStaged=$('#isByStaged'+id).val();
	if(isByStaged=='1'){
		$("input[name='stageFixed"+id+"']").show();
		$('#fixed'+id).hide();
	}else{
		$("input[name='stageFixed"+id+"']").hide();
		$('#fixed'+id).show();
	}
}

//责任贷款金额保费算法初始化
function adddept1(data){
	count=data.calls.length;
	var tableStr = "<table id='calTable' class='content_table_1'><tbody>";
	for(var i=0;i<count;i++){
		tableStr += "<tr id='count"+(i+1)+"'>"
			+"<td width='20px'>"+(i+1)+"</td>"
			+"<td>最小年份：<input id='miny"+(i+1)+"' name='miny"+(i+1)+"' value='"+data.calls[i].days+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td>最大年份：<input id='maxy"+(i+1)+"' name='maxy"+i+"' value='"+data.calls[i].maxdays+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td>部门：<input id='dept"+(i+1)+"' name='dept"+(i+1)+"' value='"+data.calls[i].codeCname+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed"+(i+1)+"' name='fixed"+(i+1)+"' value='"+ data.calls[i].premRate+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	}
	tableStr+="</tbody></table>";
	return tableStr;
}
//驾乘险table
function adddept2(){
	count1++;
	$.openLoading();
	var tableStr = "";
		tableStr +=cartable(count1) ;
	/* $('#editCalDiv').CloseDiv2(); */
	var calTd = $('#calTable');
	calTd.append(tableStr);
	/**需要导入导出*/
	if(calDefIdAll == '000000000802'||calDefIdAll == '000000000804'){
		$("#buttonHidden1").hide();
		$("#buttonHidden2").show();
		$("#buttonHidden05").hide();
	}else if(calDefIdAll == '000000000805'||calDefIdAll == '000000000806'||calDefIdAll == '000000000815'){
		$("#buttonHidden1").hide();
		$("#buttonHidden2").hide();
		$("#buttonHidden05").show();
	}
	else{
		//不需要导入导出
		$("#buttonHidden1").show();
		$("#buttonHidden2").hide();
		$("#buttonHidden05").hide();
	}
	$.closeLoading();
	/* $('#editCalDiv').OpenDiv2(); */
}
//驾乘险table
function adddept10(){
	count1++;
	$.openLoading();
	var tableStr = "";
		tableStr +=cartable1(count1) ;
	/* $('#editCalDiv').CloseDiv2(); */
	var calTd = $('#calTable');
	calTd.append(tableStr);
	/**需要导入导出*/
	if(calDefIdAll == '000000000802'||calDefIdAll == '000000000804'){
		$("#buttonHidden1").hide();
		$("#buttonHidden2").show();
		$("#buttonHidden05").hide();
	}else if(calDefIdAll == '000000000805'||calDefIdAll == '000000000806'||calDefIdAll == '000000000810'||calDefIdAll == '000000000815'){
		$("#buttonHidden1").hide();
		$("#buttonHidden2").hide();
		$("#buttonHidden05").show();
	}
	else{
		//不需要导入导出
		$("#buttonHidden1").show();
		$("#buttonHidden2").hide();
		$("#buttonHidden05").hide();
	}
	$.closeLoading();
	/* $('#editCalDiv').OpenDiv2(); */
}
//信保通
function adddept11(){
	count1++;
	$.openLoading();
	var callTypes=carType.get("callTypes");
	var tableStr ="<tr id='count"+count1+"'>"
	+"<td width='5%'>"+count1+"</td>"
	+"<td width='20%'>算法规则：<select id='cond3"+count1+"' style='width:100px' onchange=callTypeChange("+(count1)+") >"
	for (var j = 0; j < callTypes.length; j++) {
			tableStr += "<option value='"+callTypes[j].code+"'>"+callTypes[j].codeName+"</option>"
	}
	 tableStr +="</select></td>"
	+"<td width='15%'>机构：<input id='cond7"+count1+"' name='cond7"+count1+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:100px'><span class='red'>*</span></td>"
	+"<td width='15%'>费率：<input id='premRate"+count1+"' name='premRate"+count1+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:80px'>‰</td>"
	+"<td width='15%'><span>最小区间：</span><input id='cond1"+count1+"' name='cond1"+count1+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:50px' disabled='disabled'></td>"
	+"<td width='15%'><span>最大区间：</span><input id='cond2"+count1+"' name='cond2"+count1+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:50px' disabled='disabled'></td>"
	+"<td width='15%'><span>需求类型：</span><select id='cond10"+count1+"'><option value='1'>信保通</option><option value='0'>农贷通</option></select></td></tr>"
	var calTd = $('#calTable');
	calTd.append(tableStr);
	buttons();
	$.closeLoading();
	 /* $('#editCalDiv').OpenDiv2(); */
	/*if(count1>5){
		$('#calDDD').css('height','200px');
	} */
}
/**新疆信保通**/
function adddept12(data){
	count1=data.calls.length;
	var tableStr = "<table id='calTable' class='content_table_1'><tbody>";
	var callTypes=data.callTypes;
	var flag="";
	for(var i=0;i<count1;i++){
		var time2=data.calls[i].cond2;
		if(time2==null){
			time2='';
		}
		if(data.calls[i].cond3==3){
			flag="";
		}else{
			flag="disabled='disabled'"
		}
		var time1=data.calls[i].cond1;
		if(time1==null){
			time1='';
		}
		tableStr +="<tr id='count"+i+"'>"
		+"<td width='5%'>"+(i+1)+"</td>"
		+"<td width='20%'>算法规则：<select id='cond3"+(i+1)+"' style='width:100px' onchange=callTypeChange("+(i+1)+")>"
		for (var j = 0; j < callTypes.length; j++) {
   			tableStr += "<option value='"+callTypes[j].code+"'>"+callTypes[j].codeName+"</option>"
		}
		tableStr +="</select></td>"
		+"<td width='15%'>机构：<input id='cond7"+(i+1)+"' name='cond7"+(i+1)+"' value='"+data.calls[i].cond7+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:100px'><span class='red'>*</span></td>"
		+"<td width='15%'>费率：<input id='premRate"+(i+1)+"' name='premRate"+(i+1)+"' value='"+data.calls[i].premRate+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:80px'>‰</td>"
		+"<td width='15%'><span>最小区间：</span><input id='cond1"+(i+1)+"' name='cond1"+(i+1)+"' value='"+time1+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:50px' "+flag+"></td>"
		+"<td width='15%'><span>最大区间：</span><input id='cond2"+(i+1)+"' name='cond2"+(i+1)+"' value='"+time2+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)' style='width:50px' "+flag+"></td>"
		+"<td width='15%'><span>需求类型：</span><select id='cond10"+(i+1)+"'><option value='1'>信保通</option><option value='0'>农贷通</option></select></td></tr>"
	}
	tableStr+="</tbody></table>";
	/* if(count1>5){
		$('#calDDD').css('height','200px');
	}else{
		$('#calDDD').css('height','');
	} */
	return tableStr;
}
//责任按年龄区间算法初始化
function adddept3(data){
	count3=data.calls.length;
	var tableStr = "<table id='calTable' class='content_table_1'><tbody>";
	for(var i=0;i<count3;i++){
		tableStr += "<tr id='count"+(i+1)+"'>"
			+"<td width='20px'>"+(i+1)+"</td>"
			+"<td>最小年龄：<input id='cond11"+(i+1)+"' name='cond11"+(i+1)+"' value='"+data.calls[i].minAge+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td>最大年龄：<input id='cond12"+(i+1)+"' name='cond12"+(i+1)+"' value='"+data.calls[i].maxAge+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed"+(i+1)+"' name='fixed"+(i+1)+"' value='"+ data.calls[i].premRate+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	}
	tableStr+="</tbody></table>";
	if(count3>8){
		$('#calDDD').css('height','250px');
	}
	return tableStr;
}
//责任按年龄区间-分期算法初始化
function adddept13(data){
	count3=data.stagedList.length;
	var tableStr = "<table id='calTable' class='content_table_1'><tbody>";
	for(var i=0;i<count3;i++){
		var stagedArr = data.stagedList[i]["age"].split(",");
		var stageMap = data.stagedList[i]["stagedMap"];
		if (stageMap&&0==stageMap["isByStaged"]) {
			tableStr += "<tr id='count"+(i+1)+"'><td width='20px'>"+(i+1)+"</td>"
			+"<td width='150px'>是否分期：<select id='isByStaged"+(i+1)+"' onchange='isByStagedChange("+(i+1)+")' style='width:50px'><option value='0' selected='selected'>否</option><option value='1'>是</option></select></td>"
			+"<td width='120px'>最小年龄：<input id='cond11"+(i+1)+"' style='width:50px' name='cond11"+(i+1)+"' value='"+stagedArr[0]+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td width='120px'>最大年龄：<input id='cond12"+(i+1)+"' style='width:50px' name='cond12"+(i+1)+"' value='"+stagedArr[1]+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed"+(i+1)+"' name='fixed"+(i+1)+"' value='"+ stageMap["fixed"]+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>";
			for (var a = 0; a < 12; a++) {
				tableStr += "<input id='month"+(a+1)+"-"+(i+1)+"' style='display:none;width:40px;margin-right:5px' name='stageFixed"+(i+1)+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>"
			}
			tableStr += "</td></tr>";
		}else if(stageMap&&1==stageMap["isByStaged"]) {
			tableStr += "<tr id='count"+(i+1)+"'><td width='20px'>"+(i+1)+"</td>"
			+"<td width='150px'>是否分期：<select id='isByStaged"+(i+1)+"' onchange='isByStagedChange("+(i+1)+")' style='width:50px'><option value='0'>否</option><option value='1' selected='selected'>是</option></select></td>"
			+"<td width='120px'>最小年龄：<input id='cond11"+(i+1)+"' style='width:50px' name='cond11"+(i+1)+"' value='"+stagedArr[0]+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td width='120px'>最大年龄：<input id='cond12"+(i+1)+"' style='width:50px' name='cond12"+(i+1)+"' value='"+stagedArr[1]+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed"+(i+1)+"' name='fixed"+(i+1)+"' style='display:none'; value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>";
			var monthArr = stageMap["month"].split(",");
			for (var a = 0; a < monthArr.length; a++) {
				tableStr += "<input id='month"+(a+1)+"-"+(i+1)+"' name='stageFixed"+(i+1)+"' style='width:40px;margin-right:5px' value='"+monthArr[a]+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>"
			}
			tableStr += "</td></tr>"
		}
	}
	tableStr+="</tbody></table>";
	if(count3>8){
		$('#calDDD').css('height','250px');
	}
	return tableStr;
}

//责任固定保费-分期算法
function adddept14(data){
	count3=data.stagedList.length;
	var tableStr = "<table id='calTable' class='content_table_1'><tbody>";
	for(var i=0;i<count3;i++){
		var stageMap = data.stagedList[i]["stagedMap"];
		if (stageMap&&0==stageMap["isByStaged"]) {
			tableStr += "<td width='150px'>是否分期：<select id='isByStaged1' style='width:50px'><option value='0' selected='selected'>否</option></select></td>"
			+"<td><span>保费：</span><input id='fixed' name='fixed' value='"+ stageMap["fixed"]+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>";
			tableStr += "</td></tr>";
		}else if(stageMap&&1==stageMap["isByStaged"]) {
			tableStr += "<td width='150px'>是否分期：<select id='isByStaged2' style='width:50px'><option value='1' selected='selected'>是</option></select></td>"
			+"<td><span>保费：</span>";
			var monthArr = stageMap["month"].split(",");
			for (var a = 0; a < monthArr.length; a++) {
				tableStr += "<input id='month"+(a+1)+"' name='stageFixed"+(i+1)+"' style='width:40px;margin-right:5px' value='"+monthArr[a]+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'>"
			}
			tableStr += "</td></tr>"
		}
	}
	tableStr+="</tbody></table>";
	if(count3>8){
		$('#calDDD').css('height','250px');
	}
	return tableStr;
}

//天区间创建table
function adddept4(){
	count2++;
	$.openLoading();
	var tableStr = "";
		tableStr += "<tr id='count"+count2+"'>"
			+"<td width='20px'>"+count2+"</td>"
			+"<td>最小天数：<input id='cond1"+count2+"' name='cond1"+count2+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td>最大天数：<input id='cond2"+count2+"' name='cond2"+count2+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed"+count2+"' name='fixed"+count2+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	/* $('#editCalDiv').CloseDiv2(); */
	var calTd = $('#calTable');
	calTd.append(tableStr);
	buttons();
	$.closeLoading();
	/* $('#editCalDiv').OpenDiv2(); */
	if(count2>7){
		$('#calDDD').css('height','250px');
	}
}
/**按天区间算法*/
function adddept5(data){
	count2=data.calls.length;
	var tableStr = "<table id='calTable' class='content_table_1'><tbody>";
	for(var i=0;i<count2;i++){
		tableStr += "<tr id='count"+(i+1)+"'>"
			+"<td width='20px'>"+(i+1)+"</td>"
			+"<td>最小天数：<input id='cond1"+(i+1)+"' name='cond1"+(i+1)+"' value='"+data.calls[i].cond1+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td>最大天数：<input id='cond2"+(i+1)+"' name='cond2"+(i+1)+"' value='"+data.calls[i].cond2+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保费：</span><input id='fixed"+(i+1)+"' name='fixed"+(i+1)+"' value='"+ data.calls[i].premRate+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	}
	tableStr+="</tbody></table>";
	if(count2>7){
		$('#calDDD').css('height','250px');
	}
	return tableStr;
}
/**责任按天**/
function adddept9(data){
	count5=data.calls.length;
	var tableStr = "<table id='calTable' class='content_table_1'><tbody>";
	for(var i=0;i<count5;i++){
		var fate=data.calls[i].fate;
		if(fate==null){
			fate='';
		}
		var days=data.calls[i].cond1;
		if(days==null){
			days='';
		}
		tableStr += "<tr id='count"+(i+1)+"'>"
					+"<td width='20px'>"+(i+1)+"</td>"
					+"<td>保费：<input id='premRate"+(i+1)+"' name='premRate"+(i+1)+"' value='"+data.calls[i].premRate+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'><span class='red'>*</span></td>"
					+"<td><span>天数/月数/年数：</span><input id='cond1"+(i+1)+"' name='cond1"+(i+1)+"' value='"+days+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	}
	tableStr+="</tbody></table>";
	if(count5>7){
		$('#calDDD').css('height','250px');
	}else{
		$('#calDDD').css('height','');
	}
	return tableStr;
}

//按天
function adddept8(){
	count5++;
	$.openLoading();
	var tableStr = "";
		tableStr += "<tr id='count"+count5+"'>"
			+"<td width='20px'>"+count5+"</td>"
			+"<td>保费：<input id='premRate"+count5+"' name='premRate"+count5+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'><span class='red'>*</span></td>"
			+"<td><span>天数/月数/年数：</span><input id='cond1"+count5+"' name='days"+count5+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	/* $('#editCalDiv').CloseDiv2(); */
	var calTd = $('#calTable');
	calTd.append(tableStr);
	buttons();
	$.closeLoading();
	/* $('#editCalDiv').OpenDiv2(); */
	if(count5>7){
		$('#calDDD').css('height','250px');
	}else{
		$('#calDDD').css('height','');
	}
}
/**责任保额算法**/
function adddept7(data){
	count4=data.calls.length;
	var tableStr = "<table id='calTable' class='content_table_1'><tbody>";
	for(var i=0;i<count4;i++){
		var fate=data.calls[i].cond5;
		if(fate==null){
			fate='';
		}
		var days=data.calls[i].cond1;
		if(days==null){
			days='';
		}
		tableStr += "<tr id='count"+(i+1)+"'>"
					+"<td width='20px'>"+(i+1)+"</td>"
					+"<td>费率：<input id='premRate"+(i+1)+"' name='premRate"+(i+1)+"' value='"+data.calls[i].premRate+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'><span class='red'>*</span></td>"
					+"<td>系数：<input id='cond5"+(i+1)+"' name='cond5"+(i+1)+"' value='"+fate+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
					+"<td><span>保险期间：</span><input id='cond1"+(i+1)+"' name='cond1"+(i+1)+"' value='"+days+"' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	}
	tableStr+="</tbody></table>";
	if(count4>7){
		$('#calDDD').css('height','250px');
	}else{
		$('#calDDD').css('height','');
	}
	return tableStr;
}
//通用算法table
function adddept6(){
	count4++;
	$.openLoading();
	var tableStr = "";
		tableStr += "<tr id='count"+count4+"'>"
			+"<td width='20px'>"+count4+"</td>"
			+"<td>费率：<input id='premRate"+count4+"' name='premRate"+count4+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'><span class='red'>*</span></td>"
			+"<td>系数：<input id='cond5"+count4+"' name='cond5"+count4+"' value='1' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td>"
			+"<td><span>保险期间：</span><input id='cond1"+count4+"' name='cond1"+count4+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>";
	/* $('#editCalDiv').CloseDiv2(); */
	var calTd = $('#calTable');
	calTd.append(tableStr);
	buttons();
	$.closeLoading();
	/* $('#editCalDiv').OpenDiv2(); */
	if(count4>7){
		$('#calDDD').css('height','250px');
	}else{
		$('#calDDD').css('height','');
	}
}

function cartable1(carcount){
	var carTypes=carType.get("carType");
	var str="<tr id='car"+carcount+"'>"
	+"<td align='center' style='width:36%'><input type='hidden' name='useNature' id='cond7"+carcount+"'><input type='text' id='natureText' class='input_text' disabled style='width:180px'>&nbsp;<input type='button' class='input_button_2' value='车辆性质' onclick='openUseNatureDiv(this)'></td>"
	 +"<td><select id='cond8"+carcount+"' name='cond8"+carcount+"'>"
		+"<option value='0'>请选择</option>"
		if(carTypes!=null){
			for (var i = 0; i < carTypes.length; i++) {
				str+="<option value='"+carTypes[i].code+"'>"+carTypes[i].codeName+"</option>"
			}
		}
	str+="</select>"
	+"</td>"
	+"<td><input id='cond1"+carcount+"' name='cond1"+carcount+"' value='' onKeyUp='clearNoNum1(this)' onBlur='checkNum(this)'></td>"
	+"<td><input id='cond2"+carcount+"' name='cond2"+carcount+"' value='' onKeyUp='clearNoNum1(this)' onBlur='checkNum(this)'></td>"
	str+="<td><input id='fixed"+carcount+"' name='fixed"+carcount+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>"
	return str;
}
//驾乘险创建table
function cartable(carcount){
	var carTypes=carType.get("carType");
	var str="<tr id='car"+carcount+"'>"
	+"<td align='center' style='width:36%'><input type='hidden' name='useNature' id='cond7"+carcount+"'><input type='text' id='natureText' class='input_text' disabled style='width:180px'>&nbsp;<input type='button' class='input_button_2' value='车辆性质' onclick='openUseNatureDiv(this)'></td>"
	 +"<td><select id='cond8"+carcount+"' name='cond8"+carcount+"'>"
		+"<option value='0'>请选择</option>"
		if(carTypes!=null){
			for (var i = 0; i < carTypes.length; i++) {
				str+="<option value='"+carTypes[i].code+"'>"+carTypes[i].codeName+"</option>"
			}
		}
	str+="</select>"
	+"</td>"
	+"<td><input id='cond1"+carcount+"' name='cond1"+carcount+"' value='' onKeyUp='clearNoNum1(this)' onBlur='checkNum(this)'></td>"
	str+="<td><input id='fixed"+carcount+"' name='fixed"+carcount+"' value='' onKeyUp='clearNoNum(event,this)' onBlur='checkNum(this)'></td></tr>"
	return str;
}
//算法添加行--------------------------------------结束
//算法删除行--------------------------------------
function deletedept2(){
	if(count2==1){
		$.message("error","一行数据无法删除");
		return;
	}
	$('#count'+count2).remove();
	count2--;
}
function deletedept(){
	if(calDefIdAll == '000000000806'||calDefIdAll == '000000000815'||calDefIdAll == '000000000810'){
		deletedept1();
		return;
	}
	if(calDefIdAll == '000000000802'){
		deletedept2();
		return;
	}
	if(calDefIdAll == '000000000807'||calDefIdAll == '000000000884'){
		deletedept3();
		return;
	}
	if(calDefIdAll == '000000000804'){
		deletedept4();
		return;
	}
	if(calDefIdAll == '000000000813'||calDefIdAll == '000000000812'){
		deletedept5();
		return;
	}
	if(calDefIdAll == '000000000877'){
		deletedept6();
		return;
	}
	if(count==1){
		$.message("error","一行数据无法删除");
		return;
	}
	$('#count'+count).remove();
	count--;
}
function deletedept1(){
	if(count1==1){
		$.message("error","一行数据无法删除");
		return;
	}
	$('#car'+count1).remove();
	count1--;
}
function deletedept3(){
	if(count3==1){
		$.message("error","一行数据无法删除!!");
		return;
	}
	$('#count'+count3).remove();
	count3--;
}
function deletedept4(){
	if(count4==1){
		$.message("error","一行数据无法删除!!");
		return;
	}
	$('#count'+count4).remove();
	count4--;
}
function deletedept5(){
	if(count5==1){
		$.message("error","一行数据无法删除!!");
		return;
	}
	$('#count'+count5).remove();
	count5--;
}
function deletedept6(){
	if(count1==1){
		$.message("error","一行数据无法删除!!");
		return;
	}
	$('#count'+count1).remove();
	count1--;
}
//算法删除行--------------------------------------结束
//后台返回的List数据转换成前台的Map类型数据
function transListToMap(data, calDefId) {
	var calls = data.calls;// 表中已配置的费率信息  用于数据回显
	var map = new Map();
	if(calDefIdAll=="000000000804"){
		for(var i = 0; i < calls.length; i++) {
				map.put(calls[i].days, calls[i].premRate+"_"+ calls[i].cond5);
		}
	}else{
		for(var i = 0; i < calls.length; i++) {
			map.put(calls[i].days, calls[i].premRate);
		}
	}
	return map;
}
function closeCalDiv1(){
	count=1;
	count3=1;
	$("#editCalDiv").CloseDiv2();
}
//检验算法方案是否已出单
function checkOpenCalDiv(obj){
	$("#"+obj.id).blur();
	var radioCov = $("input[name='radioProPlan']:checked");
	if(radioCov.val() == undefined) {
		$.message("error","请选择一个条款");
		return;
	}
	//条款代码
	var coreRiskCode = radioCov.parent().parent().children("td:eq(2)").html();
	if('3'==coreRiskCode.substring(0,1)){
		$.message("error", "该条款为特约条款，仅做展示，该条款的保额保费需累加到主险的保额及保费中");
		return;
	}
	//保障计划Id
	var rationId = radioCov.parent().parent().children("td:eq(5)").html();
	//产品号
	var tradPlanCode = radioCov.parent().parent().children("td:eq(1)").html();// 险种代码
	tradPlanCodeAll=tradPlanCode
	$.openLoading();
	$.ajax({
		url : "product/feeRate/checkOpenCalDiv1",
		type : "POST",
		async : false,
		dataType:'json',
		data:{prodCode : tradPlanCode},
		success:function(data) {
			$.closeLoading();
			if(data != 0){
				$.dialog({
					type: "warn",
					content:"此产品已出单,确认要修改此算法?",
					onOk: function() {
						cov({prodCode : tradProdCode,
							coreRiskCode : coreRiskCode,rationId:rationId})
					}
				});
			}else{
				cov({prodCode : tradProdCode,
					coreRiskCode : coreRiskCode,rationId:rationId})
			}
		}
	});
}
var covs=new Array();
//查询已当前险种下已配置的责任
function cov(param){
	$.openLoading();
	var radio = $("input[name='radioProPlan']:checked");
	var rationId = radio.parent().parent().children("td:eq(5)").html();//保障计划编号
	$.ajax({
		url : "nlifeProductConfig/queryNewLifeCoverage1",
		type : 'POST',
		async : true,
		dataType:'json',
		data:param,
		success : function(page) {
			
			if(page.data==null){
				$.message("error","请配置责任");
				
			}else{
				 if(page.data[0].CALID == "000000000877"){
					 window.location.href='<%=path%>/nlifeProductConfig/XBTInsureEditRequest?prodCode=' + tradProdCode + '&riskCode=' + page.data[0].CORERISKCODE + '&rationId=' + rationId;
					return ;
				 }
				$.closeLoading();
				//1.
				var calStr='';
				if(page.obj!=undefined && page.obj!=null){
					for(var j= 0;j<page.obj.length;j++){
						calStr=calStr+'<option value='+page.obj[j]['CALID']+' title='+page.obj[j]['CALNAME']+'>'+page.obj[j]['CALNAME']+'</option>';
					}
				}
				var firstbutton ="<input class='input_fxk' name='radioCov' type='radio' value=''>";
				var lastbutton = "<select name='nlifeisInputAmt'onchange='checkAmountisAllowInput(this)'class='select_1'style='visibility: visible;width:80px;' disabled='disabled'><option value='Y'>固定值</option><option value='N'>比例拆分</option><option value='X'>接口传入</option></select>&nbsp;<input class='input_text'style='width:100px;'maxlength='10'name='nlifecovAmt'type='text'value='{COVAMT}'disabled='disabled'>@TDH<input class='input_text'style='width:100px;visibility: visible;'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)' name='nlifenoAmtRate' type='text'value='{AMTRATE}' disabled='disabled'>@TDH<input class='input_text' name='nlifenoAmtLimit' style='width:90px;visibility: visible;'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'type='text'value='{AMTLIMIT}' disabled='disabled'>@<input class='input_text'style='width:100px;'maxlength='13'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'name='nlifenoCalimAmount'type='text'value='{NOCALIMAMOUNT}'disabled='disabled'>@<input class='input_text'style='width:100px;'maxlength='5'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'name='nlifeclaimRate'type='text'value='{CLAIMRATE}'disabled='disabled'>@<select name='nlifecalId' class='select_1'style='visibility: visible;width:100px;'disabled='disabled'><option value=''>---请选择---</option>"+calStr+"</select>";
				var tableContent = creatTable11("coreRiskCode@TDH,coreCovCode,covName,coreCovLevel@TDH,parentCov@TDH,isInputAmount@TDH,calId@TDH",page,firstbutton,lastbutton);
				var tableObj = $("#coverageTable1");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				$("#editCovDiv1").OpenDiv5();
				var radioCovArr= $("input[type='radio'][name='radioCov']");
				for(var i= 0;i<radioCovArr.length;i++){
					var calObj = radioCovArr.eq(i).parent().parent().children(" td:eq(13)").find('select');
					$(calObj).val(page.data[i].CALID);
					var selObj = radioCovArr.eq(i).parent().parent().children(" td:eq(8)").find('select');
					$(selObj).val(page.data[i].ISINPUTAMOUNT);
				}
				bindradio3();
			}
			$.closeLoading();
		}
	});
}
/***
 * 信保通算法规则修改
 */
function callTypeChange(id){
	var callType=$('#cond3'+id).val();
	if(callType==3){
		$('#cond1'+id).attr("disabled",false);
		$('#cond2'+id).attr("disabled",false);
	}else{
		$('#cond1'+id).val('');
		$('#cond2'+id).val('');
		$('#cond1'+id).attr("disabled",true);
		$('#cond2'+id).attr("disabled",true);
	}
}
function bindradio3(){
	$("input[name='radioCov']").click(function(){
		$("input[name='radioCov']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");

   	});
}
function bindradio(){
	$("input[name='radioPlan']").click(function(){
		if (!riskMap.isEmpty()) {
			$(this).prop("checked", false);
			$.message("error", "您已选择多选框，请取消后再使用单选按钮！");
		}
		$("input[name='radioPlan']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");

   	});
}

function bindradio2(){
	$("input[name='radioProPlan']").click(function(){
		$("input[name='radioProPlan']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");

   	});
}

function searchByRiskCode(param) {
    var jsonObj = getFormParam("searchForm");
    if (!jsonObj) {
        return false;
    }
    var riskCode = jsonObj["riskCode"];
    var riskName = jsonObj["riskName"];
    loadTempPlan({current:1,size:6,coreProdCode:currCoreProdCode,tradProdCode:tradProdCode,riskCode:riskCode,riskName:riskName})
}

// 获取表单数据 返回JSON对象
function getFormParam(formId) {
    var form = $("#" + formId);
    var data = decodeURIComponent(form.serialize());
    return JSON.parse(formToJson(data));
}

// 将form序列化转换为json数据
function formToJson(data) {
    // 清除所有空格
    data = data.replace(/\s/g, "");
    data = data.replace(/&/g, "\",\"");
    data = data.replace(/=/g, "\":\"");
    data = "{\"" + data + "\"}";
    return data;
}

function loadTempPlan(param){
	$.openLoading();
	$.ajax({
		url : "nlifeProductConfig/loadCoreProdRisk",
		type : 'POST',
		async : true,
		dataType:'json',
		data:param,
		success : function(page) {
			$.closeLoading();
			if($.validate(page))return;

			startPlan = page.current;
            // <input class='input_fxk' name='radioPlan' type='radio' value=''>
			var firstbutton ="<input class='input_fxk' name='checkPlan' type='checkbox' value=''>@<input class='input_fxk' name='radioPlan' type='radio' value=''>";
			var tableContent = creatTable1("CORE_PROD_CODE,CORE_PROD_NAME,CORE_RISK_CODE,CORE_RISK_NAME,PRMRY_FLAG@TDH,RISK_TYPE@TDH",page,firstbutton,null);
			var tableObj = $("#productPlanTable");
			tableObj.find("tbody").remove();
			tableObj.append(tableContent);

			var strPage = creatChannelPage(startPlan,6,page.maxPage,"52");
			var pageDIV = $("#productPlanpageDIV");
			pageDIV[0].innerHTML="";
			pageDIV.append(strPage);
			bindradio();
			bindEven();
			chooseCoreProdCode="";
			chooseCoreRiskCode= "";
			chooseCorePrmryFlag= "";
			riskType= "";
			$("#addPlanDiv").OpenDiv();
			loadCheckRisk(page.data);
		}
	});
}
// 加载已经选择过的条款
function loadCheckRisk(data) {
	if (!riskMap.isEmpty()) {
		for (i in riskMap.keys()) {
			var key = riskMap.keys()[i];
			for (var j = 0; j < data.length; j++) {
				if(data[j].CORE_RISK_CODE === key){
					var checkPlan = $("input[name='checkPlan']")
					checkPlan.eq(j).prop("checked", true);
					checkPlan.eq(j).parent().parent().addClass("table_highlighter");
				}
			}
		}
	}
}

function loadRisk(param){
	$.openLoading();
	$.ajax({
		url : "nlifeProductConfig/loadAddedRiskInfo",
		type : 'POST',
		async : true,
		dataType:'json',
		data:param,
		success : function(data) {
			$(".rationsDIV").remove();
			$.closeLoading();
			var htmlStrs="";
			for(var i=0;i<data.length;i++){
				if(data[i].nlifeRisk.length==0){
					continue;
				}
				var htmlStr="";
				htmlStr+="<div class='rationsDIV' style='margin-top: 5px; width:100%; height:auto'>"+"<table class='table_02' id='ProdPlan' align='center' ><tbody>"
				+"<tr>"
					   +"<td colspan='6' style=' font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:27px;height:27px; background-image:url(images/centent_1.jpg)'>&nbsp;<font size='3'>保障计划:</font>&nbsp;<font size='2'>"+data[i].rationName+"</font></td></tr>"
				+"<tr><td><table id='ProdPlanTable' class='content_table_1'><thead><tr><th style='width:15%'>选择</th><th style='width:25%'>条款代码</th><th style='width:25%'>交易系统条款名称</th><th style='width:20%'>主/附加险标识</th><th style='width:15%'>操作</th></tr></thead><tbody>"
				if(data[i].nlifeRisk.length!=0){
					var risks=data[i].nlifeRisk;
					for(var j=0;j<risks.length;j++){
						var prmryFlag="";
						if(risks[j].prmryFlag==0){
							prmryFlag="主险";
						}else if(risks[j].prmryFlag==1){
							prmryFlag="附加险";
						}else if(risks[j].prmryFlag==2){
							prmryFlag="第一主险";
						}
						htmlStr+="<tr><td>"
						  +"<input class='input_fxk' name='radioProPlan' type='radio' value=''></td>"
						  +"<td style='display:none;'>"+risks[j].prodCode+"</td>"
						  +"<td>"+risks[j].coreRiskCode+"</td>"
						  +"<td>"+risks[j].riskName+"</td>"
						  +"<td>"+prmryFlag+"</td>"
						  +"<td style='display:none;'>"+risks[j].rationId+"</td>"
						  +"<td style='display:none;'>"+risks[j].prmryFlag+"</td>"
						  +"<td style='display:none;'>"+risks[j].rationName+"</td>"
						if(risks[j].prmryFlag==0){
							htmlStr+="<td>"+"<a href='javascript:void(this)' id='d"+risks[j].coreRiskCode+"' name='"+risks[j].prmryFlag+"' onClick='editMRisk("+risks[j].coreRiskCode+",this);'>修改主险</a>&nbsp<a href='javascript:void(this)' id='e"+risks[j].coreRiskCode+"' onClick='editProPlan("+risks[j].coreRiskCode+",this);'>编辑</a>&nbsp;<a href='javascript:void(0)' onClick='deleteplan("+risks[j].coreRiskCode+","+"this);'>删除</a>"+"</td></tr>"
						}else{
							htmlStr+="<td>"+"<a href='javascript:void(this)' id='e"+risks[j].coreRiskCode+"' onClick='editProPlan("+risks[j].coreRiskCode+",this);'>编辑</a>&nbsp;<a href='javascript:void(0)' onClick='deleteplan("+risks[j].coreRiskCode+","+"this);'>删除</a>"+"</td></tr>"
						}
					}
				}
				htmlStr+= "</tbody></table></td></tr></tbody></table></div>"
				htmlStrs+=htmlStr
			}

			$("#rationDiv").append(htmlStrs)
			var radios=$("input[type='radio'][name='radioProPlan']")
			for (var i = 0; i < radios.length; i++) {
				var va=radios.eq(i).parent().parent().children(" td:eq(2)").html();
				var title=$('#d'+va).attr('name');
				if(title=='1'||title=='2'){
					$('#d'+va).hide();
				}
			}
			bindradio2();
	/* 		if($.validate(page))return;

			startP = page.current;
			var firstbutton ="<input class='input_fxk' name='radioProPlan' type='radio' value=''>";
			var lastbutton = "<a href='javascript:void(this)' id='d{CORE_RISK_CODE}' name='{PRMRY_FLAG}' onClick='editMRisk({CORE_RISK_CODE},this);'>修改主险</a>&nbsp<a href='javascript:void(this)' id='e{CORE_RISK_CODE}' onClick='editProPlan({CORE_RISK_CODE},this);'>编辑</a>&nbsp;<a href='javascript:void(0)' onClick='deleteplan({CORE_RISK_CODE},{PRMRY_FLAG});'>删除</a>";

			var tableContent = creatTable2("PROD_CODE@TDH,CORE_RISK_CODE,RISK_NAME,PRMRY_FLAG?[{0:'主险'};{1:'附加险'};{2:'第一主险'}]",page,firstbutton,lastbutton);
			var tableObj = $("#ProdPlanTable");
			tableObj.find("tbody").remove();
			tableObj.append(tableContent);

			var strPage = creatChannelPage3(startP,6,page.maxPage,"53");
			var pageDIV = $("#ProdPlanpageDIV");
			pageDIV[0].innerHTML="";
			pageDIV.append(strPage);
			//附件险不显示修改主险
			var radios=$("input[type='radio'][name='radioProPlan']")
			for (var i = 0; i < radios.length; i++) {
				var va=radios.eq(i).parent().parent().children(" td:eq(2)").html();
				var title=$('#d'+va).attr('name');
				if(title=='1'||title=='2'){
					$('#d'+va).hide();
				}
			}
			bindradio2(); */
		}
	});
}



function queryNewLifeTradProdRiskInfo(pagenum){
	loadRisk({current:pagenum,size:6,tradProdCode:tradProdCode});
}

function queryNewLifeProdRisk(pagenum){
	 var chooseCoreProdCode =$("#coreProdTempletCode").val();
	var rationId = $("#ratiion_select").val();
	 if(chooseCoreProdCode.length == 0){
		$.message("error","请选择产品模板");
		return;
	 }
	loadTempPlan({current:pagenum,size:6,tradProdCode:tradProdCode,coreProdCode:chooseCoreProdCode,rationId:rationId});
}
// 加载条款后为元素绑定事件
function bindEven() {
	$("input[name='checkPlan']").click(function () {
		var branch = $(this).parent().parent().children(" td:eq(4)").html();
		if ($(this).prop("checked")) {
			$(this).parent().parent().addClass("table_highlighter");
			var chooseCoreProdCode = $(this).parent().parent().children(" td:eq(2)").html();
			var choosecoreProdName = $(this).parent().parent().children(" td:eq(3)").html();
			var chooseCoreRiskCode = $(this).parent().parent().children(" td:eq(4)").html();
			var choosecoreRiskName = $(this).parent().parent().children(" td:eq(5)").html();
			var chooseCorePrmryFlag = $(this).parent().parent().children(" td:eq(6)").html();
			var chooseriskType = $(this).parent().parent().children(" td:eq(7)").html();
			var o = new Object();
			o.coreProdCode = chooseCoreProdCode;
			o.coreProdName=choosecoreProdName;
			o.coreRiskCode = chooseCoreRiskCode;
			o.coreRiskName = choosecoreRiskName;
			o.corePrmryFlag= chooseCorePrmryFlag;
			o.riskType = chooseriskType;
			riskMap.put(branch, o);
		} else {
			$(this).parent().parent().removeClass("table_highlighter");
			$(this).prop("checked",false);
			riskMap.remove(branch);
		}
		if (!riskMap.isEmpty()) {
			$("input[name='radioPlan']").each(function () {
				$(this).prop("checked", false)
			})
		}
	})
}

function checkBatchPlan() {
	var html = '';
	if (riskMap.isEmpty() && $("input[name='radioPlan']:checked").val() == undefined) {
		$.message("请选择条款");
	}
	for (var i in riskMap.keys()) {
		var key = riskMap.keys()[i];
		var o = riskMap.get(key);
		if (i == 0) {
			html += '<tr>' +
					'<td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">条款添加</td>' +
					'</tr>' +
					'<tr>' +
					'<th width="20%">产品模板：</th>' +
					'<td width="30%">' +
					'<input name="coreProdName" id="coreProdName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text" value="' + o.coreProdName + '"><span class="red">*</span>' +
					'</td>' +
					'<th width="20%">条款模板：</th>' +
					'<td width="30%">' +
					'<input id="coreRiskName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text" value="' + o.coreRiskName + '"><span class="red">*</span>&nbsp;' +
					'<input type="button"  class="input_button_2" id="searchBtn" value="选择模板" onClick="openPlanDiv(this)"/>' +
					'</td>' +
					'</tr>' +
					'<tr>' +
					'<th>交易系统条款名称：</th>' +
					'<td>' +
					'<input name="tradRiskName" id="tradRiskName' + key + '" maxlength="100" type="text" class="input_text" value="' + o.coreRiskName + '"><span class="red">*</span>' +
					'</td><th width="20%">多保障计划：</th>' +
					'<td width="30%"><select id="ratiion_select' + key + '"  class="input_text">' +
					'<c:forEach items="${rationList}" var="ration">' +
					'<option value="${ration.rationId }">${ration.rationName }</option>' +
					'</c:forEach>' +
					'</select><span class="red">*</span>' +
					'</td>' +
					'</tr>';
		} else {
			html += '<tr style="border:2px">' +
					'<th width="20%">产品模板：</th>' +
					'<td width="30%">' +
					'<input name="coreProdName" id="coreProdName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text" value="' + o.coreProdName + '"><span class="red">*</span>' +
					'</td>' +
					'<th width="20%">条款模板：</th><' +
					'td width="30%">' +
					'<input id="coreRiskName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text" value="' + o.coreRiskName + '"><span class="red">*</span>&nbsp;' +
					'</td>' +
					'</tr>' +
					'<tr>' +
					'<th>交易系统条款名称：</th>' +
					'<td>' +
					'<input name="tradRiskName" id="tradRiskName' + key + '" maxlength="100" type="text" class="input_text" value="' + o.coreRiskName + '"><span class="red">*</span>' +
					'</td><th width="20%">多保障计划：</th>' +
					'<td width="30%"><select id="ratiion_select' + key + '"  class="input_text">' +
					'<c:forEach items="${rationList}" var="ration">' +
					'<option value="${ration.rationId }">${ration.rationName }</option>' +
					'</c:forEach>' +
					'</select><span class="red">*</span>' +
					'</td>' +
					'</tr>';
		}
		closePlanDiv();
		$("#riskInfo").html(html);
	}
}

function choosePlan(){
	var radioTemple = $("input[name='radioPlan']:checked");
	if (riskMap.isEmpty()) {
		if(radioTemple.val()!=undefined){
			chooseCoreProdCode= radioTemple.parent().parent().children(" td:eq(2)").html();
			var coreProdName = radioTemple.parent().parent().children(" td:eq(3)").html();
			chooseCoreRiskCode = radioTemple.parent().parent().children(" td:eq(4)").html();
			var coreRiskName = radioTemple.parent().parent().children(" td:eq(5)").html();
			chooseCorePrmryFlag = radioTemple.parent().parent().children(" td:eq(6)").html();
			riskType = radioTemple.parent().parent().children(" td:eq(7)").html();
			$("#coreProdName").val(coreProdName);
			$("#coreRiskName").val(coreRiskName);
			$("#tradRiskName").val(coreRiskName);
			closePlanDiv();
		}else{
			$.message("error", "请选择一个条款模板");
		}
	} else {
		checkBatchPlan();
	}

}

function openPlanDiv(obj){
	$("#"+obj.id).blur();
	loadTempPlan({current:1,size:6,coreProdCode:currCoreProdCode,tradProdCode:tradProdCode});
	$("#coreProdTempletCode").val(currCoreProdCode);
}
function closePlanDiv(){
	$("#addPlanDiv").CloseDiv();
}

function addPlan(param){
	if(!Formstatus){
		$.message("error","正在处理中");
		return;
	}
	Formstatus=false;
	$.openLoading();
	$.ajax({
		url : "nlifeProductConfig/saveRiskInfo",
		type : 'POST',
		async : true,
		dataType:'json',
		data:param,
		success : function(obj) {
			//表单状态
			Formstatus=true;
			$.closeLoading();
			if($.validate(obj))return;
			vreset();
			loadRisk({current:1,size:6,tradProdCode:tradProdCode});
		}
	});
}
//添加险种
function add(){
	if (riskMap.isEmpty()) {
		var coreProdName = $("#coreProdName").val();
		var coreRiskName = $("#coreRiskName").val();
		var tradRiskName = $("#tradRiskName").val();
		var rationId = $("#ratiion_select").val();
		var rationName = $("#ratiion_select").find("option:selected").text();
		if (coreProdName.length == 0) {
			$.message("error", "产品模板不能为空,请选择条款模板");
			return;
		} else if (coreRiskName.length == 0) {
			$.message("error", "条款模板不能为空");
			return;
		} else if (tradRiskName.length == 0) {
			$.message("error", "交易系统条款名称不能为空");
			return;
		} else if (chooseCoreProdCode.length == 0) {
			$.message("error", "产品代码不能为空");
			return;
		} else if (chooseCoreRiskCode.length == 0) {
			$.message("error", "条款代码不能为空");
			return;
		} else if (chooseCorePrmryFlag.length == 0) {
			$.message("error", "条款的主附险标识代码不能为空");
			return;
		} else if (rationId == "") {
			$.message("error", "保障计划不能为空");
			return;
		}
		addPlan({
			currCoreProdCode: currCoreProdCode,
			chooseCoreProdCode: chooseCoreProdCode,
			prodCode: tradProdCode,
			coreRiskCode: chooseCoreRiskCode,
			riskName: tradRiskName,
			prmryFlag: chooseCorePrmryFlag,
			rationId: rationId,
			rationName: rationName,
			riskType: riskType
		});
	} else {
		var	paramList = [];
		for (var i in riskMap.keys()) {
			key = riskMap.keys()[i];
			o = riskMap.get(key);
			var rationSelect = $("#ratiion_select" + key)
			o.riskName = $("#tradRiskName" + key).val();
			o.rationId = rationSelect.val();
			o.rationName = rationSelect.find("option:selected").text();
			o.prodCode = tradProdCode;
			o.currCoreProdCode = currCoreProdCode;
			if (o.coreProdName.length == 0) {
				$.message("error", key + "产品模板不能为空,请选择条款模板");
				return;
			} else if (o.coreRiskName.length == 0) {
				$.message("error", key + "条款模板不能为空");
				return;
			} else if (o.riskName.length == 0) {
				$.message("error", key + "交易系统条款名称不能为空");
				return;
			} else if (o.coreProdCode.length == 0) {
				$.message("error", key + "产品代码不能为空");
				return;
			} else if (o.coreRiskCode.length == 0) {
				$.message("error", key + "条款代码不能为空");
				return;
			} else if (o.corePrmryFlag.length == 0) {
				$.message("error", key + "条款的主附险标识代码不能为空");
				return;
			} else if (o.rationId == "") {
				$.message("error", key + "保障计划不能为空");
				return;
			}
			paramList.push(o);
		}
		addPlanBatch(JSON.stringify(paramList));
	}
}

function addPlanBatch(params) {
	if(!Formstatus){
		$.message("error","正在处理中");
		return;
	}
	Formstatus=false;
	$.openLoading();
	$.ajax({
		url : "nlifeProductConfig/saveRiskInfoBatch",
		type : 'POST',
		async : true,
		dataType:'json',
		data: params,
		contentType: "application/json",
		success : function(obj) {
			//表单状态
			Formstatus=true;
			$.closeLoading();
			if($.validate(obj))return;
			vreset();
			loadRisk({current:1,size:6,tradProdCode:tradProdCode});
		}
	})
}
function editProPlan(tradRiskCode,obj){
	var tradPlanDesc=  $(obj).parent().parent().children(" td:eq(3)").html();
	var rationId=  $(obj).parent().parent().children(" td:eq(5)").html();
	$("#eriskCode").val(tradRiskCode);
	$("#eriskName").val(tradPlanDesc);
	$("#editRationId").val(rationId);
	$("#editPlanDiv").OpenDiv();
}
function editMRisk(tradRiskCode,obj){
	$.message("error", "默认条款上限最低为第一主险，如需修改请联系管理员");
	return;
	if(!Formstatus){
		$.message("error", "正在处理中");
		return;
	}
	Formstatus=false;
	$.openLoading();
	var rationId=  $(obj).parent().parent().children(" td:eq(5)").html();
	 $.ajax({
		url : "nlifeProductConfig/updateMRisk",
		type : 'POST',
		async : true,
		dataType:'json',
		data:{prodCode:tradProdCode,tradRiskCode:tradRiskCode,coreProdCode:currCoreProdCode,rationId:rationId},
		success : function(obj) {
			Formstatus=true;
			$.closeLoading();
			$.message(obj.result,obj.message);
			loadRisk({current:1,size:6,tradProdCode:tradProdCode});
		}
	});
}

function closeEditPlanDiv(){
	$("#editPlanDiv").CloseDiv();
}

function editPlan(param){
	if(!Formstatus){
		$.message("error", "正在处理中");
		return;
	}
	Formstatus=false;
	$.openLoading();
	$.ajax({
		url : "nlifeProductConfig/updateRiskInfo",
		type : 'POST',
		async : true,
		dataType:'json',
		data:param,
		success : function(obj) {
			Formstatus=true;
			$.closeLoading();
			if($.validate(obj))return;
			loadRisk({current:1,size:6,tradProdCode:tradProdCode});
			closeEditPlanDiv();
		}
	});
}

function saveEditPlan(){
	var eriskCode=$.trim($("#eriskCode").val());
	var eriskName=$.trim($("#eriskName").val());
	var rationId =$.trim($("#editRationId").val());
	if(eriskCode.length==0){
		$.message("error","条款代码不能为空");
		return;
	}else if(eriskName.length==0){
		$.message("error","交易系统条款名称不能为空");
		return;
	}
	editPlan({prodCode:tradProdCode,coreRiskCode:eriskCode,riskName:eriskName,rationId:rationId});
}

function delplan(tradRiskCode,prmryFlag,rationId){
	$.openLoading();
	$.ajax({
		url : "nlifeProductConfig/deleteRiskInfo",
		type : 'POST',
		async : true,
		dataType:'json',
		data:{coreRiskCode:tradRiskCode,prodCode:tradProdCode,prmryFlag:prmryFlag,rationId:rationId},
		success : function(obj) {
			$.closeLoading();
			if($.validate(obj))return;
			loadRisk({current:1,size:6,tradProdCode:tradProdCode});
		}
	});
}

function deleteplan(tradRiskCode,obj){
	var rationId=  $(obj).parent().parent().children(" td:eq(5)").html();
	var prmryFlag=  $(obj).parent().parent().children(" td:eq(6)").html();
	var str='您确定要删除该条款吗？';
	if(prmryFlag=='2'){
		str='确认删除第一主险条款，删除后请选择新的第一主险条款';
	}
	$.dialog({
		type: "warn",//success,error
		content: str,
		onOk: function() {
			delplan(tradRiskCode,prmryFlag,rationId);
		}
	});
}
<%--责任配置开始 --%>
function addedCheckedInfoLogic(obj,i,calIdVal){
		/**保额文本框*/
		var $amountInput = obj.eq(i).parent().parent().children(" td:eq(11)").find('input[type="text"]');
		var flag = obj.eq(i).parent().parent().children(" td:eq(7)").html();
		var amtRate=obj.eq(i).parent().parent().children(" td:eq(12)").find('input');
		var amtLimit=obj.eq(i).parent().parent().children(" td:eq(13)").find('input');
		/**保额传入方式处理*/
 		if(flag=="N"){
			$($amountInput).attr('readonly',true);
			$($amountInput).css('background-color','#ccc');
			$(amtRate).attr('readonly',false);
			$(amtRate).css('background-color','white');
			$(amtLimit).attr('readonly',false);
			$(amtLimit).css('background-color','white');
		}else if(flag=="X"){
			$($amountInput).attr('readonly',true);
			$($amountInput).css('background-color','#ccc');
			$($amountInput).val('');
			$(amtRate).attr('readonly',true);
			$(amtRate).css('background-color','#ccc');
			$(amtLimit).attr('readonly',false);
			$(amtLimit).css('background-color','white');
		}else{
			$($amountInput).attr('readonly',false);
			$($amountInput).css('background-color','white');
			$(amtRate).attr('readonly',true);
			$(amtRate).css('background-color','#ccc');
			$(amtLimit).attr('readonly',true);
			$(amtLimit).css('background-color','#ccc');
		}
		var selObj = obj.eq(i).parent().parent().children(" td:eq(12)").find('select[name="nlifeisInputAmt"]');
		$(selObj).val(flag);
		var amtTypeObj = obj.eq(i).parent().parent().children(" td:eq(12)").find('select[name="amtType"]');
		var amtType = obj.eq(i).parent().parent().children(" td:eq(12)").find('input[type="hidden"]').val();
		amtTypeObj.val(amtType);
		var calObj = obj.eq(i).parent().parent().children(" td:eq(16)").find('select');
		var calStr=amtChange(amtType);
		//增加短期费率标志的回写；
		var shortrateFlag = obj.eq(i).parent().parent().children(" td:eq(9)").html();
		var shortrateObj = obj.eq(i).parent().parent().children(" td:eq(10)").find('select');
		if(shortrateFlag){
			$(shortrateObj).val(shortrateFlag);
		}
		if(calStr!=''){
			calObj.html(calStr);
		}
		$(calObj).val(calIdVal);
}
//算法说明文档下载
function calDocDowlaod(){
	window.location.href='<%=path%>/nlifeProductConfig/calDocDowlaod';
}
var showMap=new Map();//算法map
	//保额select改变
function amtChange(flag){
	//算法列表处理 共享保额
	var objMap=showMap.get("show");
	var calStr='';
	//共享保额
	if(flag==1){
		calStr="<option value=''>---请选择---</option>";
		if(objMap!=undefined && objMap!=null){
			for(var j= 0;j<objMap.length;j++){
					if(objMap[j]['SHOWLEVEL']>=2){
						calStr=calStr+'<option value='+objMap[j]['CALID']+' title='+objMap[j]['CALNAME']+'>'+objMap[j]['CALNAME']+'</option>';
					}
			}
		}
	}
	//固定保额，接口传入
	if(flag==2){
		calStr="<option value=''>---请选择---</option>";
		if(objMap!=undefined && objMap!=null){
			for(var j= 0;j<objMap.length;j++){
				calStr=calStr+'<option value='+objMap[j]['CALID']+' title='+objMap[j]['CALNAME']+'>'+objMap[j]['CALNAME']+'</option>';
			}
		}
	}
	return calStr;
}

function amtTypeChange(obj){
	var amtType=$(obj).val();
	var calObj = $(obj).parent().parent().children(" td:eq(15)").find('select');
	var calStr=amtChange(amtType);
	if(calStr!=''){
		calObj.html(calStr);
	}
}
function loadCoverage(param){
	$.openLoading();
	$.ajax({
		url : "nlifeProductConfig/queryNewLifeCoverage",
		type : 'POST',
		async : true,
		dataType:'json',
		data:param,
		success : function(page) {
			$.closeLoading();
			//1.
			var calStr='';
			if(page.obj!=undefined && page.obj!=null){
				for(var j= 0;j<page.obj.length;j++){
					calStr=calStr+'<option value='+page.obj[j]['CALID']+' title='+page.obj[j]['CALNAME']+'>'+page.obj[j]['CALNAME']+'</option>';
				}
				showMap.put("show",page.obj);
			}
			var shortRateFlagStr = 	"<select name='shortrateFlag' class='select_1'style='visibility: visible;width:100px;'>"
									+"<option value='1'>1-日比例</option>"
									+"<option value='2'>2-月比例</option>"
									+"<option value='3'>3-短期费率表</option>"
									+"<option value='4'>4-不计</option>"
									+"</select>"
						;
			
			var firstbutton ="<input class='input_fxk' name='checkboxCov' type='checkbox' value='#' onclick='logicHandle(this)'>";
			var lastbutton = shortRateFlagStr+"@<select name='nlifeisInputAmt'onchange='checkAmountisAllowInput(this)'class='select_1'style='visibility: visible;width:60px;'><option value='Y'>固定值</option><option value='N'>比例拆分</option><option value='X'>接口传入</option></select><select style='visibility: visible;width:60px;'class='select_1' name='amtType' onchange='amtTypeChange(this)'><option value='2'selected='selected'>每人保额</option><option value='1'>按人拆分</option><option value='3'>公共保额</option></select><input type='hidden' value='{AMTTYPE}'/>&nbsp<input class='input_text'style='width:50px;visibility: visible'maxlength='10'name='nlifecovAmt'type='text'value='{COVAMT}'>@TDH<input class='input_text'style='width:100px;visibility: visible;'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)' name='nlifenoAmtRate' type='text'value='{AMTRATE}'>@TDH<input class='input_text' name='nlifenoAmtLimit' style='width:80px;visibility: visible;'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'type='text'value='{AMTLIMIT}'>@<input class='input_text'style='width:90px;visibility: visible'maxlength='13'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'name='nlifenoCalimAmount'type='text'value='{NOCALIMAMOUNT}'>@<input class='input_text'style='width:90px;visibility: visible'maxlength='5'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'name='nlifeclaimRate'type='text'value='{CLAIMRATE}'>@<select name='nlifecalId'class='select_1'style='visibility: visible;width:100px;'><option value=''>---请选择---</option>"+calStr+"</select><a  style='color: blue;padding-left:5px; ' name='downConfig' onclick='calDocDowlaod()' href='javascript:void(this)'>算法文档</a>";
			var tableContent = creatTable11("coreRiskCode@TDH,coreCovCode,covName,coreCovAlias,coreCovLevel@TDH,parentCov@TDH,isInputAmount@TDH,calId@TDH,SHORTRATEFLAG@TDH",page,firstbutton,lastbutton);
			var tableObj = $("#coverageTable");
			tableObj.find("tbody").remove();
			tableObj.append(tableContent);

			//隐藏列属性
			var checkboxCovArr= $("input[type='checkbox'][name='checkboxCov']");
			var codeArry='';
			for(var i=0;i<checkboxCovArr.length;i++){
				var level = checkboxCovArr[i].value.split(',')[0];
				var code  = checkboxCovArr[i].value.split(',')[1];
				var calIdVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(8)").html();
				var chi = checkboxCovArr.eq(i).parent().parent().children(" td:eq(2)").html();
				if('1' == level && ""!=calIdVal){
					codeArry+=','+chi;
					checkboxCovArr[i].checked =true;
					addedCheckedInfoLogic(checkboxCovArr,i,calIdVal);
				}else if('1' == level && ""==calIdVal){
					displayOrHide(i,'hide');
				}else if('2' == level && ""==calIdVal){
					if($("input[type='checkbox'][name='checkboxCov'][value='"+'1,'+code+"']").is(':checked')){
						checkboxCovArr[i].checked =true;
					}
					displayOrHide(i,'hide');
				}else if('2' == level && ""!=calIdVal){
					checkboxCovArr[i].checked =true;
					addedCheckedInfoLogic(checkboxCovArr,i,calIdVal);
				}
			}
			
			 //查询当前节点一级节点是否存在
			for(var i=0;i<checkboxCovArr.length;i++){
				var calIdVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(8)").html();
				//对应一级责任代码
				var par = checkboxCovArr.eq(i).parent().parent().children(" td:eq(6)").html();
				var val = checkboxCovArr.eq(i).parent().parent().children(" td:eq(2)").html();
				if(par!=""&&val!=par){
					if(codeArry.indexOf(par)!=-1){
						checkboxCovArr[i].disabled=true;
					}
				}
			}
			$("#editCovDiv").OpenDiv();
		}
	});
}

//校验是否需要输入保额
function checkAmountisAllowInput(obj){
	var caldefVal = $(obj).val();
	var amtType = $(obj).parent().find('select[name="amtType"]');
	var $amountInput = $(obj).siblings('input');
	var armRate=$amountInput.parent().parent().children("td:eq(12)").find('input');
	var armLimit=$amountInput.parent().parent().children("td:eq(13)").find('input');
	if(caldefVal=="N"){
		$($amountInput).attr('readonly',true);
		$($amountInput).css('background-color','#ccc');
		$($amountInput).val('');
		$(armRate).attr('readonly',false);
		$(armRate).css('background-color','white');
		$(armLimit).attr('readonly',false);
		$(armLimit).css('background-color','white');
		$(amtType).children(":eq(0)").attr("selected","selected");
		$(amtType).children(":eq(2)").hide();
	}else if(caldefVal=="X"){
		$($amountInput).attr('readonly',true);
		$($amountInput).css('background-color','#ccc');
		$($amountInput).val('');
		$(armRate).val('');
		$(armRate).attr('readonly',true);
		$(armRate).css('background-color','#ccc');
		$(armLimit).attr('readonly',false);
		$(armLimit).css('background-color','white');
		$(amtType).children(":eq(0)").attr("selected","selected");
		$(amtType).children(":eq(2)").hide();
	}else{
		$($amountInput).attr('readonly',false);
		$($amountInput).css('background-color','white');
		$(armRate).attr('readonly',true);
		$(armRate).css('background-color','#ccc');
		$(armRate).val('');
		$(armLimit).attr('readonly',true);
		$(armLimit).css('background-color','#ccc');
		$(armLimit).val('');
		$(amtType).children(":eq(0)").attr("selected","selected");
		$(amtType).children(":eq(2)").show();
	}
}

function saveCoverage(param){
	if(!Formstatus){
		$.message("error","正在处理中");
		return;
	}
	Formstatus=false;
	$.openLoading();
	$.ajax({
		url : "nlifeProductConfig/saveNewLifeCoverage?"+new Date().getTime(),
		type : 'POST',
		async : true,
		dataType:'json',
 		data:{jsonStr:param},
		success : function(obj) {
			$.closeLoading();
			Formstatus=true;
			if($.validate(obj))return;
			$("#editCovDiv").CloseDiv();

		}
	});
}
/**
 * 保存责任保额
 */
function saveCov(){
	var saveDataAry=[];
	var checkboxCovArr= $("input[type='checkbox'][name='checkboxCov']:checked");//所有选中的checkboxes
	var radioCov = $("input[name='radioProPlan']:checked");
	for(var i=0;i<checkboxCovArr.length;i++){
		//20230909 新增一个td 在10号位置 原大于等于9的+1
		var shortrateFlag = checkboxCovArr.eq(i).parent().parent().children(" td:eq(10)").find('select[name="shortrateFlag"]').val();
		var inputflag =checkboxCovArr.eq(i).parent().parent().children(" td:eq(11)").find('select[name="nlifeisInputAmt"]').val();
		var amtType =checkboxCovArr.eq(i).parent().parent().children(" td:eq(11)").find('select[name="amtType"]').val();
		var covAmtval = checkboxCovArr.eq(i).parent().parent().children(" td:eq(11)").find('input[type="text"]').val();
		var covAmtCss = checkboxCovArr.eq(i).parent().parent().children(" td:eq(11)").find('input[type="text"]');
		var noCalimAmountVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(14)").find('input').val();
		var noCalimAmountCss = checkboxCovArr.eq(i).parent().parent().children(" td:eq(14)").find('input');
		var claimRateVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(15)").find('input').val();
		//var claimRateCss = checkboxCovArr.eq(i).parent().parent().children(" td:eq(11)");
		var calIdVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(16)").find('select').val();
		var calIdCss = checkboxCovArr.eq(i).parent().parent().children(" td:eq(16)").find('select');
		var amtRate= checkboxCovArr.eq(i).parent().parent().children("td:eq(12)").find('input').val();
		var amtRateCss = checkboxCovArr.eq(i).parent().parent().children(" td:eq(14)").find('input');
		var amtLimit= checkboxCovArr.eq(i).parent().parent().children("td:eq(13)").find('input').val();
		var amtLimitCss = checkboxCovArr.eq(i).parent().parent().children(" td:eq(14)").find('input');
		var rationId =  radioCov.parent().parent().children(" td:eq(5)").html();
		var rationName =  radioCov.parent().parent().children(" td:eq(7)").html();
		if('Y'==inputflag && covAmtval ==''){
			$.message("error","当保额类型为  [固定值] 时请输入保额");
	    	return;
		}else if('N'==inputflag &&'none'!=amtRateCss.css('display') ){
			if(amtRate ==''){
				$.message("error","当保额类型为  [接口传入] 时请输入保额占比");
		    	return;
			}else{
				 var reg = new RegExp("^(([1-9][0-9]*)|0)(\.[0-9]{1,6})?$");
				 var flag= reg.test(amtRate);
				 if(!flag){
					$.message("error","输入保额占比 必须为有效数字且最多保留6位小数");
			    	return;
				 }
			}
		}else if('N'==inputflag && amtLimit ==''&&'none'!=amtLimitCss.css('display')){
			$.message("error","当保额类型为  [接口传入] 时请输入保额上限");
	    	return;
		}
	    var reg = new RegExp("^(([1-9][0-9]*)|0)(\.[0-9]{1,2})?$");
		if('none'!= covAmtCss.css('display') && covAmtval!=""){
		    var flag= reg.test(covAmtval);
		    if(!flag){
		    	$.message("error","输入金额必须为有效数字且最多保留2位小数");
		    	return;
		    }
		    //没有小数点情况下，输入金额长度不能超过8位数字
		    var strval = covAmtval+"";
		    var idx = strval.indexOf('.');
		    if(idx==-1){
		    	if(strval.length>8){
		    		$.message("error","输入金额长度不能超过8位数字");
		    		return;
		    	}
		    }
		}
		if('none'!=noCalimAmountCss.css('display') && ""!=noCalimAmountVal){
			 var flag= reg.test(noCalimAmountVal);
			 if(!flag){
		    	$.message("error","输入免赔金额必须为有效数字且最多保留2位小数");
		    	return;
			 }
		}
		if('none'!=calIdCss.css('display') && calIdVal.length == 0){
	    	$.message("error","请选择责任保费算法");
	    	return;
		}

		var coreRiskCodeVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(1)").html();
		var coreCovCodeVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(2)").html();
		var coreCovNameVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(3)").html();
		var coreCovLevelVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(5)").html();
		var parentCovVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(6)").html();
		if('2'==coreCovLevelVal){
			coreCovCodeVal=coreCovCodeVal.substr(1);
			coreCovNameVal=coreCovNameVal.substr(1);
			if(!$("input[type='checkbox'][name='checkboxCov'][value='"+'1,'+checkboxCovArr[i].value.split(',')[1]+"']").is(':checked')){
				parentCovVal="";
			}else{
				inputflag=''
			}
		}
		if(coreCovCodeVal==parentCovVal){
			parentCovVal="";
		}
		var data={amtRate:amtRate,amtLimit:amtLimit,prodCode:tradProdCode,coreRiskCode:coreRiskCodeVal,coreCovCode:coreCovCodeVal,covName:coreCovNameVal,parentCov:parentCovVal,isInputAmount:inputflag,covAmt:covAmtval,noCalimAmount:noCalimAmountVal,claimRate:claimRateVal,calId:calIdVal,amtType:amtType,rationId:rationId,rationName:rationName,shortrateFlag:shortrateFlag};

		saveDataAry.push(data);
		}
		//保存责任保额
		saveCoverage(JSON.stringify(saveDataAry));

	}

	//点击”配置责任“打开责任Div
	function openCovDiv(obj) {
		$("#" + obj.id).blur();
		var radioCov = $("input[name='radioProPlan']:checked");
		if (radioCov.val() == undefined) {
			$.message("error", "请选择一个条款");
			return;
		}
		var coreRiskCode = radioCov.parent().parent().children("td:eq(2)").html();
		if('3'==coreRiskCode.substring(0,1)){
			$.message("error", "该条款为特约条款，仅做展示，该条款的保额保费需累加到主险的保额及保费中");
			return;
		}
		var rationId = radioCov.parent().parent().children("td:eq(5)").html();
		loadCoverage({
			prodCode : tradProdCode,
			coreRiskCode : coreRiskCode,
			rationId:rationId
		});
	}

	function closeCovDiv() {
		$("#editCovDiv").CloseDiv();
	}
	function closeCovDiv1() {
		$("#editCovDiv1").CloseDiv();
	}
<%-- checkbox logic--%>
function logicHandle(obj){
	var level = obj.value.split(',')[0];
	var code  = obj.value.split(',')[1];
	var checkboxCovArr= $("input[name='checkboxCov']");
	var checkboxCovArr1= $("input[name='checkboxCov']");
	if(obj.checked){
		for(var i=0;i<checkboxCovArr.length;i++){
			var calIdVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(16)").find('select').val();
			var inputflag =checkboxCovArr.eq(i).parent().parent().children(" td:eq(11)").find('select').val();
			var covAmtval = checkboxCovArr.eq(i).parent().parent().children(" td:eq(11)").find('input').val();
			if(obj.value == checkboxCovArr[i].value && checkboxCovArr[i].checked && calIdVal==""&&inputflag=='N'){
				displayOrHide(i,'show');
			}
			if('1'==level){
				if("2,"+code == checkboxCovArr[i].value){
					checkboxCovArr[i].checked=true;
					displayOrHide(i,'hide');
				}
			}else if('2'==level){
				if("1,"+code == checkboxCovArr[i].value){
					checkboxCovArr[i].checked=false;
					displayOrHide(i,'hide');
				}
			}
		}
		if('1'==level){
			//查询当前节点一级节点是否存在
			for(var i=0;i<checkboxCovArr1.length;i++){
				var calIdVal = checkboxCovArr1.eq(i).parent().parent().children(" td:eq(8)").html();
				//对应一级责任代码
				var par = checkboxCovArr1.eq(i).parent().parent().children(" td:eq(6)").html();
				var val = checkboxCovArr1.eq(i).parent().parent().children(" td:eq(2)").html();
				if(par==code&&val!=par){
					checkboxCovArr1[i].disabled=true;
				}
			}
		}
	}else if(!obj.checked){
		for(var i=0;i<checkboxCovArr.length;i++){
			var calIdVal = checkboxCovArr.eq(i).parent().parent().children(" td:eq(14)").find('select').val();
			if(obj.value == checkboxCovArr[i].value && !checkboxCovArr[i].checked){
				displayOrHide(i,'hide');
			}
			if('1'==level){
				if("2,"+code == checkboxCovArr[i].value){
					checkboxCovArr[i].checked=false;
				}
			}else if('2'==level){
				if("1,"+code == checkboxCovArr[i].value){
					checkboxCovArr[i].checked = false;
					displayOrHide(i,'hide');
				}else{
					if(obj.value == checkboxCovArr[i].value && checkboxCovArr[i].checked && calIdVal==""&&inputflag=='N' && covAmtval==''){
						displayOrHide(i,'show');
					}else if(obj.value == checkboxCovArr[i].value && checkboxCovArr[i].checked && calIdVal!=""){
						continue;
					}
				}
			}
		}
		if('1'==level){
			//查询当前节点一级节点是否存在
			for(var i=0;i<checkboxCovArr1.length;i++){
				var calIdVal = checkboxCovArr1.eq(i).parent().parent().children(" td:eq(8)").html();
				//对应一级责任代码
				var par = checkboxCovArr1.eq(i).parent().parent().children(" td:eq(6)").html();
				if(par==code){
					checkboxCovArr1[i].disabled=false;
				}
			}
		}
	}
}

function displayOrHide(i,type){
	var covAmt= $("input[name='nlifecovAmt']");
	var selObj = $("select[name='nlifeisInputAmt']");
	var noCalimAmount = $("input[name='nlifenoCalimAmount']");
	var claimRate = $("input[name='nlifeclaimRate']");
	var calId = $("select[name='nlifecalId']");
	var amtRate = $("input[name='nlifenoAmtRate']");
	var amtLimit = $("input[name='nlifenoAmtLimit']");
	var amtType = $("select[name='amtType']");
	var downConfig=$("a[name='downConfig']");
	if('hide'==type){
		selObj.eq(i).val("N");
		selObj.eq(i).css('display','none');
		covAmt.eq(i).val('');
		covAmt.eq(i).css('display','none');
		amtRate.eq(i).val('');
		amtRate.eq(i).css('display','none');
		amtLimit.eq(i).val('');
		amtType.eq(i).css('display','none');
		amtLimit.eq(i).css('display','none');
		noCalimAmount.eq(i).val('');
		noCalimAmount.eq(i).css('display','none');
		claimRate.eq(i).val('');
		claimRate.eq(i).css('display','none');
		calId.eq(i).val('');
		downConfig.eq(i).css('display','none');
		calId.eq(i).css('display','none');
	}else if('show'==type){
		selObj.eq(i).val("Y");
		checkAmountisAllowInput(selObj.eq(i));
		selObj.eq(i).css('display','');
		covAmt.eq(i).val("");
		covAmt.eq(i).css('display','');
		amtRate.eq(i).val('');
		amtRate.eq(i).css('display','');
		amtLimit.eq(i).val('');
		amtType.eq(i).css('display','');
		amtLimit.eq(i).css('display','');
		noCalimAmount.eq(i).val("");
		noCalimAmount.eq(i).css('display','');
		claimRate.eq(i).val("");
		claimRate.eq(i).css('display','');
		calId.eq(i).val('');
		calId.eq(i).css('display','');
		downConfig.eq(i).css('display','');
	}

}
function vreset(){
	$("#coreProdName").val("");
	$("#coreRiskName").val("");
	$("#tradRiskName").val("");
	if (!riskMap.isEmpty()) {
		riskMap.clear();
	}
	var html = '<tr>' +
			'<td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">条款添加</td>' +
			'</tr>' +
			'<tr>' +
			'<th width="20%">产品模板：</th>' +
			'<td width="30%">' +
			'<input name="coreProdName" id="coreProdName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>' +
			'</td>' +
			'<th width="20%">条款模板：</th>' +
			'<td width="30%">' +
			'<input id="coreRiskName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;' +
			'<input type="button"  class="input_button_2" id="searchBtn" value="选择模板" onClick="openPlanDiv(this)"/>' +
			'</td>' +
			'</tr>' +
			'<tr>' +
			'<th>交易系统条款名称：</th>' +
			'<td>' +
			'<input name="tradRiskName" id="tradRiskName" maxlength="100" type="text" class="input_text"><span class="red">*</span>' +
			'</td><th width="20%">多保障计划：</th>' +
			'<td width="30%"><select id="ratiion_select"  class="input_text">' +
			'<c:forEach items="${rationList}" var="ration">' +
			'<option value="${ration.rationId }">${ration.rationName }</option>' +
			'</c:forEach>' +
			'</select><span class="red">*</span>' +
			'</td>' +
			'</tr>';
	$("#riskInfo").html(html);
}

</script>
<style>
	.input_text {
	padding-left: 3px;
	}
	</style>
</head>
<body>
<div class="right" id="rationDiv">
	      <div class="current">
	           <table class="current_table_1">
	              <tbody>
		              <tr>
		                <td><img src="./images/current_1.jpg"></td>
		                  <td class="current_table_1_td"><img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
			                  <span style=" color:#136bab; ">新意健险产品管理
			                  <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>产品配置
			                  <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>条款添加
			                  </span>
		                  </td>
		                  <td><img src="./images/current_3.jpg"></td>
		              </tr>
	           	  </tbody>
	           </table>
	      </div>
	      <div>
			<form id="inputForm" >
			<table class="table_05">
	              <tbody>
		    		  <tr>
 		              	<td style="line-height:23px;">
 		              		<font color="#3876bf"><b>产品代码：</b></font> ${tradProdCode}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#3876bf"><b>产品名称：</b></font>${tradProdDesc}
 		              	</td>
		              </tr>
	           	  </tbody>
	         </table>
	        <table class="table_05" id="riskInfo">
	              <tbody>
		              <tr>
		                  <td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">条款添加</td>
		              </tr>
		    		  <tr>
		                  <th width="20%">产品模板：</th>
		                  <td width="30%"><input name="coreProdName" id="coreProdName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span></td>
		                  <th width="20%">条款模板：</th>
		                  <td width="30%"><input id="coreRiskName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;<input type="button"  class="input_button_2" id="searchBtn" value="选择模板" onClick="openPlanDiv(this)"/></td>
		              </tr>
		              <tr>
		                  <th>交易系统条款名称：</th>
		                  <td><input name="tradRiskName" id="tradRiskName" maxlength="100" type="text" class="input_text"><span class="red">*</span></td>
		              	  <th width="20%">多保障计划：</th>
		                  <td width="30%">
	                 		<select id="ratiion_select"  class="input_text">
	                			<c:forEach items="${rationList}" var="ration">
	                				<option value="${ration.rationId }">${ration.rationName }</option>
	                			</c:forEach>
	                 		</select><span class="red">*</span>
	                  	</td>
		              </tr>
	           	  </tbody>
	         </table>
	         <div align="center">
	             <input class="input_button_1" name="" type="button" onclick="add()" value="保存">&nbsp;&nbsp;
		         <input class="input_button_1" name="" type="button" onclick="vreset()"value="重置">
	         </div>
	         </form>
	      </div>
	      <input class="input_button_2" id="openCovDiv" name="" type="button" onclick="openCovDiv(this)" value="配置责任">
	      <input class="input_button_2" id="openCalDiv" name="" type="button" onclick="checkOpenCalDiv(this)" value="算法配置">
	      <input class="input_button_2" id="openAuwConfigDiv" name="" type="button" onclick="openAuwConfigDiv(1)" value="核保规则">
	      <!-- 条款列表 -->
<%-- 	     <c:forEach items="${rationList}" var="ration">
	      <div style="margin-top: 5px;">
	         <table class="table_02" id="ProdPlan" align="center" >
				<tbody>
					<tr>
						   <td colspan="6" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:27px;height:27px; background-image:url(images/centent_1.jpg)">&nbsp;${ration.rationName}</td>
					</tr>
					<tr>
						<td>
							<table id="ProdPlanTable" class="content_table_1">
								<thead>
									<tr >
									   <th style="width:15%">选择</th>
					                   <th style="width:25%">条款代码</th>
								       <th style="width:25%">交易系统条款名称</th>
								       <th style="width:20%">主/附加险标识</th>
								       <th style="width:15%">操作</th>
					              	</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
							<div id="ProdPlanpageDIV"  class="page"></div>
						</td>
					</tr>
				</tbody>
			</table>
	      </div>
	 </c:forEach> --%>

</div>
		<!--添加模板 DIV-->
  		<div id="addPlanDiv" style="display:none;width:80%;overflow-y: auto;">
		<input type="hidden" id="row_num" name="row_num" value="0"/>

			<div style='width:100%;height:20px;line-heighe:20px;background-color:#A4BDE3'>
					<table class="table_title">
						<tr>
						<td width="70px"></td>
						<td width="100%" id="interfaceName"></td>
						<td width="40px" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closePlanDiv()"/></td>
						</tr>
					</table>
			</div>
			<div>
					<table class="search_table" align="center">
						<tr>
							<td style="text-align: center">产品模板：&nbsp;&nbsp;${currCoreProdCode}-${currCoreProdName }
								<input id="coreProdTempletCode" value="${currCoreProdCode}" type="hidden"/>
							<%-- <select id="coreProdTempletCode"  class="select_1" style="visibility: visible;">

	                  		<c:forEach var ="coreProdCodels" items="${coreProdCodels}">
	                  			<option value="${coreProdCodels.coreProdCode}" title="${coreProdCodels.coreProdName}">${coreProdCodels.coreProdName}</option>
	                  		</c:forEach>
	                  	 	</select> --%></td>
						</tr>
					</table>
			</div>
			<div>
				<form method="post" id="searchForm" name="searchForm" onsubmit="return false" action="">
					<table class="search_table">
						<tr>
							<td style="text-align: right">条款模板代码：</td>
							<td style="text-align: left"><input name="riskCode" id="riskCode"></td>
							<td style="text-align: right">条款模板名称：</td>
							<td style="text-align: left"><input name="riskName" id="riskName"></td>
							<td style="text-align: center" colspan="2"><input id="searchButton" name="searchButton" type="button"
																			  class="input_button_1" value="查询" onclick="searchByRiskCode()"></td>
						</tr>
					</table>
				</form>
			</div>
			<table class="table_02" id="addPlanTable"  align="center" >
				<tbody>
					<tr>
						<td>
							<table id="productPlanTable"  class="content_table_1">
								<thead>
									<tr class="f1">
					                  <th style="width:10%">多选</th>
									  <th style="width:10%">选择</th>
					                  <th style="width:10%">产品模板代码</th>
					                  <th style="width:30%">产品模板名称</th>
					                  <th style="width:10%">条款模板代码</th>
					                  <th style="width:40%">条款模板名称</th>
					              	</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
							<div id="productPlanpageDIV"  class="page"></div>
						</td>
					</tr>
				</tbody>
			</table>
			<div align="center">
			 <input class="input_button_3" name="" type="button" onclick="choosePlan()" value="确定">&nbsp;&nbsp;
	         <input class="input_button_3" name="" type="button" onclick="closePlanDiv()"  value="取消">
			</div>
	</div>

	<!--添加责任保额-->
  		<div id="editCovDiv" style="display:none;width:95%;">
		<input type="hidden" id="row_num" name="row_num" value="0"/>

			<div style='width:100%;line-heighe:20px;background-color:#A4BDE3'>
					<table class="table_title">
						<tr>
						<td width="70px"></td>
						<td width="100%" id="interfaceName"></td>
						<td width="40px" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeCovDiv()"/></td>
						</tr>
					</table>
			</div>
			<div style="width:100%;height:400px;overflow: scroll;">
			<form id="covForm" >
			<table class="table_02" id="addCovDivTable" align="center" >
				<tbody>
					<tr>
						<td>
							<table id="coverageTable"  class="content_table_1" >
								<thead>
									<tr class="f1">
									  <th style="width:3%">选择</th>
					                  <th style="width:7%">责任代码</th>
					                  <th style="width:9%">责任名称</th>
					                  <th style="width:7%">责任别名</th>
					                  <th style="width:9%">短期费率标志</th>
					                  <th style="width:15%">保额</th>
					                  <th style="width:11%;display:none">保额占比(6位小数)</th>
					                  <th style="width:7%;display:none">保额上限</th>
					                  <th style="width:10%">免赔额(2位小数)</th>
					                  <th style="width:9%">赔付比例（%）</th>
					                  <th style="width:15%">责任保费算法</th>
					              	</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
			<div align="center">
			 <input class="input_button_3" name="" type="button" onclick="saveCov()" value="保存">&nbsp;&nbsp;
	         <input class="input_button_3" name="" type="button" onclick="closeCovDiv()"  value="取消">
			</div>
			</form>
			</div>
	</div>
	<!--算法配置显示责任列表-->
  		<div id="editCovDiv1" style="display:none;width:90%; overflow-y:auto;">
		<input type="hidden" id="row_num" name="row_num" value="0"/>

			<div style='width:100%;height:20px;line-heighe:20px;background-color:#A4BDE3'>
					<table class="table_title">
						<tr>
						<td width="70px"></td>
						<td width="100%" id="interfaceName"></td>
						<td width="40px" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeCovDiv1()"/></td>
						</tr>

					</table>
			</div>
			<form id="covForm" >
			<table class="table_02" id="addCovDivTable1" align="center" >
				<tbody>
					<tr>
						<td>
							<table id="coverageTable1"  class="content_table_1">
								<thead>
									<tr class="f1">
						 			  <th style="width:5%">选择</th>
					                  <th style="width:7%">责任代码</th>
					                  <th style="width:15%">责任名称</th>
					                  <th style="width:20%">保额</th>
					                  <th style="width:12%;display:none">保额占比(6位小数)</th>
					                  <th style="width:10%;display:none">保额上限</th>
					                  <th style="width:10%">免赔额(2位小数)</th>
					                  <th style="width:10%">赔付比例（%）</th>
					                  <th style="width:10%">责任保费算法</th>
					              	</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
			<div align="center" id="covButton">
					<input class="input_button_2" name="" type="button" onclick="checkOpenCalDiv1()" value="算法配置">
			<input class="input_button_3" name="" type="button" onclick="closeCovDiv1()" value="取消">
	 		</div>
			</form>
	</div>
		<!-- 配置产品核保规则的Div -->
	<div id="auwConfigDiv" style="display:none;width:70%;">
		<div class="table_title_div">
			<table class="table_title" style="width:98%;height:20px;">
				<tr>
					<td width="10%"></td>
					<td width="80%" id="interfaceName"></td>
					<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAuwConfigDiv('auwConfigDiv')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" id="table" style="width:98%;" align="center">
			<tr>
				<td>
					<div style="height:300px">
						<table id="auwConfigsDivTable"  class="content_table_1">
							<thead>
								<tr class="f1">
									<th style="width:5%"><input id="auwConfigCheckAll" type="checkbox"></th>
									<th style="width:15%">核保规则ID</th>
									<th style="width:80%">核保规则描述</th>
				              	</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
					</div>
					<div id="userRoleDivPage" class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center">
			<input type="button" id="saveRoleBtn" value="保存" onclick="saveAuwConfig()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
			<input type="button" value="取消" onclick="closeAuwConfigDiv('auwConfigDiv')" class="input_button_3"/>
		</div>
	</div>
	<!--   	添加模板 DIV 默认隐藏-->
	<div id="editPlanDiv"  style="display:none;width:60%">
			<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="/manager/images/closedown.gif" alt="关闭"  onclick="closeEditPlanDiv()"/></td>
						</tr>
					</table>
			</div>
			<!-- 修改id 名 -->
			<table class="table_02" id="addtempletTable" align="center">
				<tbody>
					<tr>
						<td>
							<table id="addRiskInfoTable"  class="content_table_1" style="height:90px;border: 0px; ">

								<tbody>
									<tr>
					                  <td width="40%" style="text-align:right;border-right:0px;">条款代码：&nbsp;&nbsp;</td>
					                  <td width="60%" style="text-align:left"><input name="eriskCode" id="eriskCode" readonly="readonly" style=" background-color: #ccc;" type="text" class="input_text"></td>
					                </tr>
					                <tr>
					                  <td width="40%" style="text-align:right;border-right:0px;">交易系统条款名称：&nbsp;&nbsp;</td>
					                  <td width="60%" style="text-align:left"><input name="eriskName" id="eriskName" type="text" maxlength="100" class="input_text"><span class="red">*</span></td>
					                </tr>
								</tbody>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
			<div align="center">
				<input type="hidden" id="editRationId" value="">
			   <input class="input_button_3" name="" type="button" onclick="saveEditPlan()" value="确定">&nbsp;&nbsp;
	           <input class="input_button_3" name="" type="button" onclick="closeEditPlanDiv()" value="取消">
			</div>
	</div>
	<!-- 算法配置Div -->
	<div id="editCalDiv" style="display:none; width: 90%">
		<input type="hidden" id="row_num" name="row_num" value="0"/>
		<div style='width:100%;height:20px;line-heighe:20px;background-color:#A4BDE3'>
			<table class="table_title">
				<tr>
					<td width="70px"></td>
					<td width="100%" id="interfaceName" align="center"><h3 id="titleDiv"></h3></td>
					<td width="40px" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeCalDiv1()"/></td>
				</tr>
			</table>
		</div>

		<div style="width:100%;">
			<form id="calForm">
				<div id="calDDD" style="width:100%;overflow:auto;height: 300px">
				<span class="blue" style="float: right;" id='remark'>说明：保费随保险天数区间不同而不同,cond1:天数下限，cond2:天数上限，上下限全是闭区间</span>
					<table id="addCovDivTable" class="table_20" align="center">
						<tbody>
							<tr>
								<td id="calTd">
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div align="center" id="buttonHidden1">
					<input class="input_button_3" name="" type="button" onclick="saveCal()" value="保存">&nbsp;&nbsp;
			        <input class="input_button_3" name="" type="button" onclick="closeCalDiv1()" value="取消">
				</div>
				<div align="center" id="buttonHidden05">
					<input class="input_button_3" name="" type="button" onclick="saveCal()" value="保存">&nbsp;&nbsp;
					<input class="input_button_2" name="" type="button" onclick="adddept()" value="添加行">&nbsp;&nbsp;
					<input class="input_button_2" name="" type="button" onclick="deletedept()" value="删除行">&nbsp;&nbsp;
			        <input class="input_button_3" name="" type="button" onclick="closeCalDiv1()" value="取消">
				</div>
				<div align="center" id="buttonHidden02">
				<table style="width:100%;">
						<tr>
							<td width="40%">
								&nbsp;&nbsp;<input class="input_button_2" name="" type="button" onclick="calTemplateDownLoad()" value="模板下载">
								&nbsp;<input class="input_button_2" name="" type="button" onclick="calTemplateImport()" value="数据导入">
							</td>
							<td width="60%">
								<input class="input_button_3" name="" type="button" onclick="saveCal()" value="保存">&nbsp;&nbsp;
			        			<input class="input_button_2" name="" type="button" onclick="adddept()" value="添加行">&nbsp;&nbsp;
								<input class="input_button_2" name="" type="button" onclick="deletedept()" value="删除行">&nbsp;&nbsp;
			        			<input class="input_button_3" name="" type="button" onclick="closeCalDiv1()" value="取消">
							</td>
						</tr>
					</table>
					</div>
				<div style="display: none;" id="buttonHidden2">
					<table style="width:100%;">
						<tr>
							<td width="40%">
								&nbsp;&nbsp;<input class="input_button_2" name="" type="button" onclick="calTemplateDownLoad()" value="模板下载">
								&nbsp;<input class="input_button_2" name="" type="button" onclick="calTemplateImport()" value="数据导入">
							</td>
							<td width="60%">
								<input class="input_button_3" name="" type="button" onclick="saveCal()" value="保存">&nbsp;&nbsp;
			        			<input class="input_button_3" name="" type="button" onclick="closeCalDiv1()" value="取消">
							</td>
						</tr>
					</table>
				</div>
			</form>
		</div>
	</div>
		<!-- excel导入界面-->
	<div id="calTemplateImportDiv"  style="display:none;width:50%;height: 30%;background-color:#f6f7f9;">
        	<div class="table_title_div">
				<table class="table_title" style="width:100% ;height: 20px;">
					<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeCalTemplateImportDiv()"/></td>
					</tr>
				</table>
			</div>

	   		<form id="chooseReconciliationFileForm" action="" method="POST" enctype="multipart/form-data" >
	     		<table class="table_02" style="width: 92%" align="center">
	     			<tr>
	     				<td style="padding:25px 20px ">
	     					请选择批量更新文件：<input type="file" id="reconciliationFile" name="reconciliationFile"/>
	        				<input type="button" class="input_button_1" value="导入" onClick="reconciliationFileChose()"/>
	     				</td>
	     			</tr>
	     		</table>
	     	</form>
        </div>
        	<!-- 选择车辆使用性质Div -->
	<div id="useNatureDiv" style="display:none;width:50%;">
		<div class="table_title_div">
			<table class="table_title" style="width:98%;height:20px;">
				<tr>
					<td width="10%"></td>
					<td width="80%" id="interfaceName"></td>
					<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeUseNatureDiv('useNatureDiv')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" id="table" style="width:98%;" align="center">
			<tr>
				<td>
					<div style="height:135px">
						<table id="useNatureDivTable"  class="content_table_1">
							<thead>
								<tr class="f1">
									<th style="width:5%"><input id="useNatureCheckAll" type="checkbox"></th>
									<th style="width:45%">车辆使用性质描述</th>
									<th style="width:50%">车辆使用性质ID</th>
				              	</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
					</div>
				</td>
			</tr>
		</table>
		<div align="center">
			<input type="button" id="saveUseNatureBtn" value="确定" onclick="saveUseNature();" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
			<input type="button" value="取消" onclick="closeUseNatureDiv('useNatureDiv');" class="input_button_3"/>
		</div>
	</div>
</body>
</html>